I have this headache
The Code:
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$("#dvContent").append("<ul class='list'></ul>");
$.ajax({
type: "GET",
url: "file.xml",
dataType: "xml",
success: function(xml){
$(xml).find('entry').each(function(){
var sTitle = $(this).find('title').text();
// HERE I Need to add onClick attr
// Por example (added to <a>)
$("<li></li>").html("<a onclick='example('https://yahoo.com/');' href='http://google.com/'>" + sTitle + '</a>').appendTo("#dvContent ul");
// but I'ts the Result: (with-out Slash and ['])
$("<li></li>").html("<a onclick="example(" https:="" www.yahoo.com=""');'" href='http://google.com/'>" + sTitle + '</a>').appendTo("#dvContent ul");
$("<li></li>").html("<a href='http://google.com/'>" + sTitle + '</a>').appendTo("#dvContent ul");
});
},
error: function() {
alert("An error occurred while processing XML file.");
}
});
}); </script>
In the line 19 aprox <a>
I need to add [onclick='example('http://yahoo.com/');']
How can I solve this?
I realized that are deleting the Slashes and quotes
Aucun commentaire:
Enregistrer un commentaire