ITeye博客

可以自行输入的下拉框 select带输入 可以输入的select下拉框

freejs · 2014-11-03 09:23 · Web前端 · Markdown

可以自行输入的下拉框 select带输入 可以输入的select下拉框

 

可以自行输入的下拉框 select带输入 可以输入的select下拉框

演示

 

JavaScript Code

  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3. $("select").customComboBox({
  4. tipText : "Enter Your Value",
  5. tipClass : "mytipclass",
  6. allowed : /[A-Za-z0-9$.s]/,
  7. notallowed : /[<>]/,
  8. index : 'last',
  9. isEditing : function(el, status, value) {
  10. if (typeof window.console!='object') { return; }
  11. console.info('Editing status changed to (', status, ') on ', el, ' combo box and the selected value is "', value, '"');
  12. },
  13. onKeyDown : function(el, character, fulltext) {
  14. if (typeof window.console!='object') { return; }
  15. console.info('The character (', character, ') was just typed into ', el, ' combo box and the complete text is now "', fulltext, '"');
  16. },
  17. onDelete : function(el, fulltext) {
  18. if (typeof window.console!='object') { return; }
  19. console.info('A character was deleted from ', el, ' combo box and the complete text is now "', fulltext, '"');
  20. }
  21. });
  22. $("form p").find('input').on('click',function(e) {
  23. var sel = $(e.currentTarget).prev('select');
  24. var name = sel.attr('name').toUpperCase();
  25. var val = sel.find('option:selected').val();
  26. $("#result").text(name+" combo box value is " + val);
  27. });
  28. });
  29. </script>

 

XML/HTML Code

  1. <form style="margin-top:100px;">
  2. <p><strong>jQuery Plugins</strong><br/>
  3. <select name='Plugins'>
  4. <option value="jQueryScript.Net">freejs.net</option>
  5. <option value="jQuery.Com">jQuery.Com</option>
  6. <option value="Google.com">Google.com</option>
  7. </select>
  8. <input type='button' value='Submit' />
  9. </p>
  10. <p><strong>Pizza Toppings</strong><br/>
  11. <select name='pizza'>
  12. <option value="pepperoni">Pepperoni</option>
  13. <option value="extra cheese">Extra Cheese</option>
  14. <option value="banana peppers">Banana Peppers</option>
  15. </select>
  16. <input type='button' value='Submit' />
  17. </p>
  18. <p><strong>price</strong><br/>
  19. <select name='donation'>
  20. <option value="10.00">10.00</option>
  21. <option value="20.00">20.00</option>
  22. <option value="30.00">30.00</option>
  23. </select>
  24. <input type='button' value='Submit' />
  25. </p>
  26. </form>

 

原文地址:http://www.freejs.net/article_biaodan_308.html

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。