I just need to get all attributes and text from given string via RegExp, if it’s possible with one line RegExp would be wonderful. I want to get each attr from string if it is in ” or ‘ or standalone.
- Attr:
value = "1" or value = '1' or value="1" or value='1' or value=1 or value="" - Attr:
readonly or disabled
I tried, this but not works for me.
var s = '<option value="1" data-foo="Foo" readonly>Value 1</option>', m
m = s.match(/<option ([^>]*)>(.*)<\/option>/)
console.log(m)
// gives ["<option value="1" data-...adonly>Value 1</option>", "value="1" data-foo="Foo" readonly", "Value 1"]
Thanks a lot.
Actually I was needing this for handling “option” elements with a more simple way, more simple regexp. Cos of ie doesn’t not append if use
innerHTML = append contentforselectelements. Append operation is mentioned at links below, but does not work for option elements. And than I find a solution for this problem. If append content is option or options than usehandleOptionElements, if not useasyncInnerHTML.http://james.padolsey.com/javascript/asynchronous-innerhtml/
Ways to increase performance when set big value to innerHTML