Return to Snippet

Revision: 48863
at December 5, 2011 07:26 by tcam27


Updated Code
$(document).ready(function(){
var thename;
var theid;
$('*').each(function() {
if($(this).attr("name"))
{
thename=$(this).attr("name");
$(this).attr("id",thename);
}

});
$('*').each(function() {
if($(this).attr("id"))
{
theid=$(this).attr("id");
$(this).attr("name",theid);
}

});
});

Revision: 48862
at July 12, 2011 02:01 by tcam27


Initial Code
$(document).ready(function(){
var thename;
var theid;
$('*').each(function() {
if($(this).attr("name"))
{
thename=$(this).attr("name");
$(this).attr("id",thename)
}

});
$('*').each(function() {
if($(this).attr("id"))
{
theid=$(this).attr("id");
$(this).attr("name",theid)
}

});
});

Initial URL


Initial Description
Since forms only read the name of the element and not the id, this could be helpful since it makes each each element's name its id and its id the name.

Initial Title
Set All HTML Element Names and IDs to the Other

Initial Tags
html, jquery

Initial Language
jQuery