Saturday, November 17, 2012

jquery – inside javascript string change html tag value

So, I\’ve got a string. The string contains html. I\’m checking the string for \’name\’, if it doesn\’t have one I\’m using sneaking one in there if it does I need to change what it is.



var myString = \'<input id=\"accountUser_c967817c993e62b1de50e4f0401a03ae\" type=\"hidden\" value=\"c967817c993e62b1de50e4f0401a03ae\" name=\"addRow[]\"><div class=\"colors goldbluegreenorange\"></div>\';
if (myString.indexOf(\'name\') == -1) {
myString = myString.substr(0,myString.indexOf(\'>\')) + \' name=\"addRow[]\"\' + myString.substr(myString.indexOf(\'>\'));
} else {
//get what\'s inside name\'s quotes and change it to removeRow[].
}


I\’ve got jquery going on too, if that makes more sense than straight javascript.






Rating: 2 out of 5 based on 5 ratings



The post jquery – inside javascript string change html tag value appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/jquery-inside-javascript-string-change-html-tag-value.html

No comments:

Post a Comment