Ok so i have this 开发者_开发知识库
<select class="something">
<option value=''>
Select a Project
</option>
---
</option>
<option value="/projects/2">test</option>
<option value="/projects/3">test2</option>
<option value="/projects/4">test7</option>
<option value="/projects/5">test5</option>
When someone clicks the Select a Project how would popup a lightbox just for that and not if they select the others....Popping up the lightbox is not too hard its distinquishing from the other options that i dont understand
$(".something").change
this will get all but i only want "Select a Project"
$('.something').change(function() {
if ($(this).val() == '') {
// Your code here:
}
});
Here's how I'd do it:
$(".something").bind("change", function(eventObj) {
if($(":selected",this).text() === "Select a Project") {
// open lightbox
}
});
I like checking .val()
in most cases, but if your value is an empty string...I feel iffy about it so I would check against the text of the selected option in this case.
精彩评论