Skip to content Skip to sidebar Skip to footer

Get The Id/name Of An Element From Dynamically Generated Html Jquery

How can I get the id or name of input element of type='text' from dynamically generated HTML. I need to get the Id of

Solution 1:

Descriptiom

Your <input name="ctl00$DefaultContent$ctl2" type="text" class="TextNormal" /> has no id attribute. But you can get a collection of every input type text using this selector $("input[type='text']). I think you want to get the name attribute.

Check out the sample and this jsFiddle Demonstration.

Sample

$(function() {
    $("input[type='text']").each(function() {
       alert("id = " + $(this).attr("id")); 
       alert("name = " + $(this).attr("name")); 
    });
});

More Information

Update

Your input element has a class attribute. You can get all elements that has this class using

$(".TextNormal").each(function() {
    alert("id = " + $(this).attr("id")); 
    alert("name = " + $(this).attr("name")); 
});

Post a Comment for "Get The Id/name Of An Element From Dynamically Generated Html Jquery"