开发者

jquery and selecbox, disallowing

$('#my_select').live("click", function(e) {
    e.preventDefault(); //开发者_Go百科return false also fails.
    alert("test"); //or show my dialog
});

Having a such live action, I want to disable how dropdown options appear once I click the selectbox, instead I want to display my own div which changes the value. However the code above doesn't disallow it and I don't want to used disabled= "disabled" attribute as it fails for further server based validations.


http://jsfiddle.net/MhTet/

This should help you :)

in case link broken :)

$('select').live("mousedown", function(e) {
    e.preventDefault(); //return false also fails.
    //alert("test"); //or show my dialog
    return;
});


That is not really possible. If you really have to do this (consider the impact to accessibly!), then you'l need to replace the whole select element. There are several ready made JavaScript libraries that can do that for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜