How (using Javascript or jQuery) can I detect when a value has been selected from a select box, even if it s the same option as was previously selected (i.e. no change event is fired).
最重要的是,我需要这种互动,但为关键板工作的解决办法也是多余的。
How (using Javascript or jQuery) can I detect when a value has been selected from a select box, even if it s the same option as was previously selected (i.e. no change event is fired).
最重要的是,我需要这种互动,但为关键板工作的解决办法也是多余的。
唯一可操作的解决办法是,通过在<代码>上设定<条码>>的>条码/代码>对<条码>上其他部分的数值,使<条码>变更/代码>活动发生。 在标志中,我提出了一种额外选择(即第一个孩子),将其藏匿起来(ides/FF/Safari, IE与往常一样)。 因此,它看着罚款。
<select>
<option style="display: none"></option>
<option>First</option>
<option>Second</option>
<option>Third</option>
</select>
然后使用jQuery,我们约束change
和mousedown
。 <代码>Mousedownstarts,select
将其价值与隐蔽选择的价值挂钩。
$("select").on({
change: function() {
console.log($(this).val());
},
mousedown: function() {
$(this).val($(":first", this).val());
}
});
http://jsfiddle.net/LzNrS/“rel=”nofollow。 http://jsfiddle.net/LzNrS/。
<><>UPDATE: 为了在用户点击<条码>但决定不选择任何东西时保留所选定的数值,我们可以修改该代码增加<条码>蓝色/代码>活动和更新<条码>。
var special = ""; // special hidden option value
var value = ""; // temporary variable
$("select").on({
change: function() {
console.log($(this).val());
},
mousedown: function() {
if (this.value == special) {
$(this).val(value);
return;
}
value = this.value;
$(this).val(special);
},
blur: function() {
if (this.value == special)
$(this).val(value);
}
});
http://jsfiddle.net/LzNrS/1/“rel=”nofollow。 http://jsfiddle.net/LzNrS/1/。
如果你能够把活动手放在选定的盒子选择要素上,并用点击其价值的话,我就不赞成。
works with mouse, doesn t work with keyboard http://jsfiddle.net/w4DEJ/4/
I think focus() function will help you..try this: http://api.jquery.com/focus/
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...
I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph? The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.