JQuery 绑定select标签的onchange事件,弹出选择的值,并实现跳转、传参
web jQuery 2021-07-08 1526 0
关于本站

“最难不过坚持”

本人承接扒站仿站,php网站维护,病毒查杀,网站编辑,网站改版,html制作

有需要网站维护,改版,病毒查杀,网站编辑,网站备案,html制作等相关的工作可以联系我。
本人有多年相关工作经验,也可提供免费咨询,交个朋友。
有需要探讨问题的朋友,也可以加我微信,共同探讨!
微信:15011482830 QQ:408917339

6472416 2614 39
最新评论
https://jueru.net/
评 留言
:weixiao:
评 留言
:shuijiao: :weiqu: :zhenbang: :leng:
评 留言
:yiwen: :yiwen: :yiwen: :yiwen:
评 EasySass: could not generate CSS file. See Output panel for details.
这个业务逻辑多少都有点奇怪了,阅读浏览次数增值在新闻详情页的控制器方法里setInc,这怎么还写进模型事件里了。如果非要用onAfterRead也可以,把新闻文章的内容单独分出来一个news_content表,然后把它和news做关联,然后给news_content表的onAfterRead事件做增值处理,这样点进新闻页内查询到文章内容时才会触发它。
评 TP6模型事件-查询后onAfterRead不好用
文章标签更多
ThinkPHP (254)
Mysql (58)
DedeCms (33)
jQuery (67)
证件照 (1)
setInc (4)
setDec (4)
onclick (5)
打开边栏(ESC) 关闭边栏(ESC)

<script src="jquery.min.js" type="text/javascript"></script>  
<script language="javascript" type="text/javascript">  
  $(document).ready(function(){  
    $('#mySelect').change(function(){  
      alert($(this).children('option:selected').val());  
      var p1=$(this).children('option:selected').val();//这就是selected的值  
      var p2=$('#param2').val();//获取本页面其他标签的值  
      window.location.href="xx.php?param1="+p1+"m2="+p2+"";//页面跳转并传参  
    })  
})  
</script>
<select id="mySelect">  
  <option value="1">one</option>  
  <option value="2" selected="selected">two</option>  
  <option value="3">three</option>  
</select>
<input type="text" value="ooo" name="param2" id="param2"/> 
jquery获取select选择的文本与值
获取select 选中的 text :
$("#ddlregtype").find("option:selected").text();
获取select选中的 value:

$("#ddlregtype ").val();
获取select选中的索引:

$("#ddlregtype ").get(0).selectedindex;
1、获取选中select的value和text,html代码如下:

<select id="mySelect">  
         <option value="1">one</option>  
         <option value="2">two</option>  
         <option value="3">three</option>  
     </select>  
1、则可通过以下script代码s来获取选中的value和text

$("#mySelect").val(); //获取选中记录的value值  
$("#mySelect option:selected").text(); //获取选中记录的text值
2、运用new Option("文本","值")方法添加选项option :

var obj = document.getElementById("mySelect");  
    obj.add(new Option("4","4"));
3、删除所有选项option:

var obj = document.getElementById("mySelect");  
    obj.options.length = 0;
4、删除选中选项option:

var obj = document.getElementById("mySelect");  
 var index = obj.selectedIndex;  
   obj.options.remove(index);  
5、修改选中选项option

var obj = document.getElementById("mySelect");  
var index = obj.selectedIndex;  
  obj.options[index] = new Option("three",3); //更改对应的值  
  obj.options[index].selected = true; //保持选中状态 
6、删除select:

var obj = document.getElementById("mySelect");  
    obj.parentNode.removeChild(obj); //移除当前对象  
7、select选择的响应事件:

$("#mySelect").change(function(){  
    //添加所需要执行的操作代码  
    })    

版权声明:本篇文章来源于网络。 来源链接

相关推荐
jQuery出现Uncaught TypeError: $(...).prop is not a function问题
jQuery | 2019-08-23 6341
做全选功能的时候用到 var xz = $(this).prop("checked"); 提示: Uncaught TypeError: $(...).prop is not a function 应该是jquery版本过低造成的,更换高版本成功解决问题, jquery下载地址 http://www...
TypeError: e.indexOf is not a function解决方法
jQuery | 2020-06-23 6339
This error might be caused by jquery event aliases like .load, .unload or .error deprecated since jQuery 1.8. Look for these aliases in your code and replace them with .o...
评论:0条
评论加载中...
发表评论