javascript - Prototype Selection Help -
Hey guys, I'm trying to make a little extra for any web app using. Right now I am trying to check all the checkboxes on the page, in which the class .checkbox
( is required to select / select the case ). Checkboxes are the descendants of the class .someClass
, it's just that there are many divs that are classes.
& lt ;! - Check this box - & gt; & Lt; Div class = "some class" & gt; [...] & lt; Input type = "checkbox" class = "check box" /> gt; & Lt; / Div & gt; & Lt ;! - But this one is not - & gt; & Lt; Div class = "some class other class lolvat" & gt; [...] & lt; Input type = "checkbox" class = "check box" /> gt; & Lt; / Div & gt;
Remember, checkboxes are not direct children, but lineage
Thank you, I appreciate any help.
Here you can Can go:
& lt ;! DOCTYPE html public "- // W3C // DTD XHTML 1.0 Transcriptional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" xml: lang = "en" lang = "en" & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Title & gt; Check the box & lt; / Title & gt; & Lt; Script src = "prototype.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Function checkThem () {// Get All .someClass divs $$ (". SomeClass") Filter each item (items) {// Additional classes if (item.className == 'someClass') {// checkbox items are available.} Select ('. Checkbox'). (Checkbox) {// Check them checkbox. Checked = true;});}}); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt ;! - Check this box - & gt; & Lt; Div class = "some class" & gt; Check: & lt; Input type = "checkbox" class = "check box" /> gt; Input type = "checkbox" class = "checkbox" /> gt; & Lt; / Div & gt; & Lt ;! - But this one is not - & gt; & Lt; Div class = "some class other class lolWut" & gt; Do not check: & lt; Input type = "checkbox" class = "check box" /> gt; & Lt; / Div & gt; & Lt ;! - Check this box - & gt; & Lt; Div class = "some class" & gt; Check: & lt; Input type = "checkbox" class = "check box" /> gt; Input type = "checkbox" class = "checkbox" /> gt; & Lt; / Div & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; A href = "#" onclick = "CheckTheme (); Return Back;" & Gt; Check them out. & Lt; / A & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment