I have a string of HTML tags and i want to retrieve all the attribute named 'name'. What should i do?
<input type="radio" name="read"/>
<input type="radio" name="write"/>
<input type="radio" name="speak"/>
I want to get read, write and speak.
try this
$(document).ready(function(){
var string = '<input type="radio" name="read"/><input type="radio" name="write"/><input type="radio" name="speak"/>';
getStringname(string);
});
function getStringname(string){
$('body').append('<div id="createdDivforinput" style="display:none;">'+string+'</div>');
$('#createdDivforinput input').each(function() {
alert($(this).attr('name'));
});
$('#createdDivforinput').remove();
}
.attr()or.prop()