| selector not working
|
ctoz

msg:4295121 | 10:45 pm on Apr 10, 2011 (gmt 0) | Hopefully, the last problem for a while: the function below is supposed to select a span which is the child of a class and add some text to the span. The html looks like this: <p class="a1">some text<span></span></p> The class is a variable... 'a1' 'a2' etc. function addTxt(myline) { $(myline > span).html(' more text '); } called with addTxt('.a1'). Firefox is giving the error message 'span is undefined'. There may be a clue here: if it's changed to $(p.myline > span).html(' more text '); the error message changes to 'p is undefined'. I could give the spans a class, but that would make the code heavier as there are hundreds of em. Any ideas?
|
mbabuskov

msg:4295127 | 10:59 pm on Apr 10, 2011 (gmt 0) | selector should be a string, you're passing '.a1' as a string, so you need to concatenate to get the complete string: $(myline+' > span').html(' more text'); HTH -- Milan B. [edited by: engine at 1:58 pm (utc) on Apr 15, 2011] [edit reason] no sig files, thanks [/edit]
|
ctoz

msg:4295187 | 1:45 am on Apr 11, 2011 (gmt 0) | Milan, it sure did!
|
|
|