At some point in my javascript, I create a div with the following code:
var myDiv = document.createElement('div');
myDiv.className = 'square';
myDiv.id = originalID;
...
myDiv.myAttribute = myValue;
Later on, I wish to modify it, so I try to select it with this code:
$("div[myAttribute ='"+ myValue +"']")
However, I am unable to modify myDiv with this code!
$("div[myAttribute ='"+ myValue +"']").id = newID;
So I am trying to debug with this alert:
alert(JSON.stringify($("div[myAttribute ='"+ myValue +"']")));
But it shows a mess of stuff:
{
"length":0,
"prevObject":{
"0":{
"location":{
"href":"http://localhost:3000/",
"origin":"http://localhost:3000",
"protocol":"http:",
"host":"localhost:3000",
"hostname":"localhost",
"port":"3000",
"pathname":"/",
"search":"",
"hash":""
}
},
"context":{
"location":{
"href":"http://localhost:3000/",
"origin":"http://localhost:3000",
"protocol":"http:",
"host":"localhost:3000",
"hostname":"localhost",
"port":"3000",
"pathname":"/",
"search":"",
"hash":""
}
},
"length":1
},
"context":{
"location":{
"href":"http://localhost:3000/",
"origin":"http://localhost:3000",
"protocol":"http:",
"host":"localhost:3000",
"hostname":"localhost",
"port":"3000",
"pathname":"/",
"search":"",
"hash":""
}
},
"selector":"div[myAttribute='myValue']"
}
How do I form the statement to use the selector to modify that element's ID?