


The onchange event bound to the select tag in JQuery then pops up the selected value and implements jumps and parameter transfers.
The onchange event bound to the select tag in JQueryThen pop up the selected value and implement jump and parameter passing
<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 Get the text and value selected by select
Get the selected text of select:
$("#ddlregtype").find("option:selected").text();
Get the value selected by select:
$("#ddlregtype ").val();
2. Get the index selected by select:
$("#ddlregtype ").get(0).selectedindex;
1. Get the value and text of the selected select, the html code is as follows:
<select id="mySelect"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
Copy after login
You can use the following script code s to get the selected value and text
$("#mySelect").val(); //获取选中记录的value值 $("#mySelect option:selected").text(); //获取选中记录的text值
var obj = document.getElementById("mySelect"); obj.add(new Option("4","4"));
3, deleteall options option
var obj = document.getElementById("mySelect"); obj.options.length = 0;
4, delete selected option option
var obj = document.getElementById("mySelect"); var index = obj.selectedIndex; obj.options.remove(index);
5, Modify the selected option option
var obj = document.getElementById("mySelect"); var index = obj.selectedIndex; obj.options[index] = new Option("three",3); //更改对应的值 obj.options[index].selected = true; //保持选中状态
6, delete select
var obj = document.getElementById("mySelect"); obj.parentNode.removeChild(obj); //移除当前对象
7, select the selected response event
$("#mySelect").change(function(){ //添加所需要执行的操作代码 })
The above is the detailed content of The onchange event bound to the select tag in JQuery then pops up the selected value and implements jumps and parameter transfers.. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

When browsing Douyin works, we often see a clock icon behind the tag. So, what exactly is this clock? This article will focus on the discussion of "What is the clock behind the Douyin label", hoping to provide some useful reference for your use of Douyin. 1. What is the clock behind the Douyin label? Douyin will launch some hot topic challenges. When users participate, they will see a clock icon after the tag, which means that the work is participating in the topic challenge and displays the remaining time of the challenge. For some time-sensitive content, such as holidays, special events, etc., Douyin will attach a clock icon after the label to remind users of the validity period of the content. 3. Popular tags: When a tag becomes popular, Douyin will add a clock icon after the tag to indicate that the tag is

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

As a popular short video social platform, Douyin has a huge user base. For Douyin creators, using tags to attract traffic is an effective way to increase the exposure of content and attract attention. So, how does Douyin use tags to attract traffic? This article will answer this question in detail for you and introduce related techniques. 1. How to add tags on Douyin to attract traffic? When posting a video, make sure to choose tags that are relevant to the content. These tags should cover the topic and keywords of your video to make it easier for users to find your video through tags. Leveraging popular hashtags is an effective way to increase your video’s exposure. Research current popular tags and trends and incorporate them into your video descriptions and tags. These popular tags usually have higher visibility and can attract the attention of more viewers. 3. Label

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s
