Monday, July 30, 2012

How to retrieve the html tag attributes in jquery and javascript?



I have tried the following code to draw a table from an array and retrieve the attribute id from the rows. Any suggestions would be appreciated immensely.



$(document).ready(function(){

$.get(\'php/php.php\', function(data){
$.each(data, function(index, value){
$(\'table\').append(
\"<tr id=\'someid\'>\"
+\"<td>\"+value.ticker+\"</td>\"
+\"<td>\"+value.bid+\"</td>\"
+\"</tr>\");
});
}, \"json\");

$(\'tr\').click(function(){
var id = $(this).attr(\"id\");
alert(id);

})

});






Rating: 4 out of 5 based on 3 ratings



The post How to retrieve the html tag attributes in jquery and javascript? appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/how-to-retrieve-the-html-tag-attributes-in-jquery-and-javascript.html

No comments:

Post a Comment