I'm using polymer, and jquery to change an attribute of a tag, if one tag's attribute is false, using an if/else statement, currently the one I am using doesn't work, how would I make it work? Here is what I have so far:
<p flex>Would you like notifications on?</p> <paper-toggle-button checked="false" id="onoff"></paper-toggle-button>
<p flex>Private Message Notifications?</p> <paper-toggle-button checked="true" id="pmn" class="blue"></paper-toggle-button>
<p flex>Game Update Notifications?</p> <paper-toggle-button checked="true" id="gun" class="lightgrey"></paper-toggle-button>
<p flex>Website Update Notifications?</p> <paper-toggle-button checked="true" id="wun" class="pink"></paper-toggle-button>
var main = document.querySelector('#onoff');
var pmn = document.querySelector('#pmn');
var wun = document.querySelector('#wun');
var gun = document.querySelector('#gun');
if ( $('#onoff').attr('checked') == 'true' ) {
// do this
} else {
pmn.removeAttribute("checked");
wun.removeAttribute("checked");
gun.removeAttribute("checked");
pmn.setAttribute("disabled", "true");
wun.setAttribute("disabled", "true");
gun.setAttribute("disabled", "true");
}
I currently have #onoff checked="false" so the other toggles would automatically be disabled and the attribute checked would equal false, but it doesn't, anyone can tell me what I'm doing wrong, and how to fix it?
Aucun commentaire:
Enregistrer un commentaire