jquery - How to get value from a DIV element using 'this' -


i trying id number later can use in jquery post. id number in variable called data.results[i].id. how can id number jquery post below.

for (var in data.results)  {    document.getelementbyid("list-canvas").innerhtml += "<div id='list_element" +      data.results[i].id + "' value=" + data.results[i].id +      " class='list_element_class'>" +     "<div id='list_image'>" +     "<div id='actual_image'>" + data.results[i].feature_image +     "</div>" +     "</div>" +     "</div>";    $('.list_element_class').on('click', this.id, function(){     $.post('sql_p.php', {id : this.value }, function(data)            {       $("#left_2").hide();$("#left_3").show();       document.getelementbyid("left_3").innerhtml = data;     });   }); } 

there nothing wrong "this.id" contain given element id, "this.value" comes undefined.

a div not have value. form elements do.

you can use value attribute, have getattribute (.attr('value') in jquery)


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -