makata Posted June 23, 2013 Share Posted June 23, 2013 (edited) I want to replace $('#topspeed').change(function(){with a condition, something like if($("[id=topspeed]").....How to do it? Here's the HTML <select id="topspeed" ><option data-icon="arrow-u" data-iconpos="top" >- SELECT -</option ></select> Edited June 23, 2013 by makata Link to comment Share on other sites More sharing options...
davej Posted June 25, 2013 Share Posted June 25, 2013 (edited) What you're asking doesn't make sense unless maybe you mean something like this... <script>$(document).ready(function(){ $("select").change(function(){ if(this.value=='SELECT1'){ alert('SELECT1'); }else if (this.value=='SELECT2'){ alert('SELECT2'); }else{ alert('Other'); } });});</script> Edited June 25, 2013 by davej Link to comment Share on other sites More sharing options...
dsonesuk Posted June 25, 2013 Share Posted June 25, 2013 IF! you are checking if id ref exists if($('#topspeed').length){//do somesthing} or for value if($('#topspeed').val() == 'whatever'){//do somesthing} but you stiil need event to run this for example onload, change or click. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now