用户操作
[留言]  [发消息]  [加为好友] 
订阅我的博客
XML聚合    FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
Larmy888的公告
愿结交天下编程爱好者!<br> <img src='http://www.blog.edu.cn/UploadFiles/2005-12/1221810043.jpg' width='160'> <br> <!-- Search Google --> <form method="get" action="http://www.google.cn/custom" target="google_window"> <table bgcolor="#ffffff"> <tr><td nowrap="nowrap" valign="top" align="left" height="32"> <a href="http://www.google.com/"> <img src="http://www.google.com/logos/Logo_25wht.gif" border="0" alt="Google" align="middle"></img></a> <br/> <label for="sbi" style="display: none">输入您的搜索字词</label> <input type="text" name="q" size="17" maxlength="255" value="" id="sbi"></input> </td></tr> <tr><td valign="top" align="left"> <label for="sbb" style="display: none">提交搜索表单</label> <input type="submit" name="sa" value="搜索" id="sbb"></input> <input type="hidden" name="client" value="pub-5876139298472571"></input> <input type="hidden" name="forid" value="1"></input> <input type="hidden" name="ie" value="GB2312"></input> <input type="hidden" name="oe" value="GB2312"></input> <input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1"></input> <input type="hidden" name="hl" value="zh-CN"></input> </td></tr></table> </form> <!-- Search Google --> <script type="text/javascript"><!-- google_ad_client = "pub-5876139298472571"; google_ad_width = 160; google_ad_height = 600; google_ad_format = "160x600_as"; google_ad_type = "text_image"; google_ad_channel = ""; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <script type="text/javascript"><!-- google_ad_client = "pub-5876139298472571"; google_ad_width = 160; google_ad_height = 600; google_ad_format = "160x600_as"; google_cpa_choice = "CAEaCKn-kHRShep5UDRQDVAFUAg"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
文章分类
Blog
Bulletin(RSS)
shaokun305的专栏
steady's JSF Zone
vc
漂亮(RSS)
趣味漫画
铭琦狼件--技术高超,web报表
韩小明@xiammy的专栏
存档

原创  JQuery一日一练(select的各种操作) 收藏

abc

  //select选项添加
  $('#optionAdd').click(function(){
      var s = $('#txtSelect').val();
   if(s != ''){
       s = '<option>' + s + '</option>';
       $('#ll').append(s);
   }else{
    alert('不能为空');
   }
  });
  
  //select选项删除
  $('#optionDel').click(function(){
   $('#ll option[selected]').remove();
  });
  
  //select选项修改
  $('#optionEdit').click(function(){
   $('#ll option[selected]').text('ycj');
  });
  
  //获取select更改后的值
  $('#ll').change(function(){
   $('#txtSelect').val($(this).val());
  });
  
  //select 元素中的比较
  $('#optionCompare').click(function(){
  
      //方法1
   $('#result').text('no'); 
      for(i=0; i<$('#ll option').length; i++){
    if($('#ll option').eq(i).text() == $('#txtSelect').val()){
     $('#result').text('yes'); 
    }
   }
  
      //方法2
   $('#result').text('no'); 
   $('#ll option').each(function(){
    if($(this).text() == $('#txtSelect').val()){
     $('#result').text('yes'); 
    }
   });
  
  });

个人感觉添加操作不理想,但暂时也找不到什么好的办法

发表于 @ 2008年01月09日 22:05:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:WINDOWS2003+IIS环境下PHP配置心得 | 新一篇:NSIS入门程序实例,麻雀虽小,五脏俱全

  • 发表评论
  • 评论内容:
  •  
Copyright © Larmy888
Powered by CSDN Blog