Case analysis of selecting Trigger event for select dropdown box based on jquery _jquery

Source: Internet
Author: User

The example in this article describes the implementation method of selecting trigger events based on the jquery Select dropdown box. Share to everyone for your reference, specific as follows:

I have always believed that the Select dropdown box selects options with the OnClick registration event, as follows:

<select>
  <option value= "0" onclick= "func (0)" > option one </option>
  <option value= "1" onclick= " Func (1) "> option two </option>
</select>

Today, there is a request to do linkage menu, is every point, adjacent to the Drop-down box will automatically change, I think no problem ah, the onclick walk

So we went up the line and the client said, IE8 must support, I think also, XP's IE kernel can only rise to IE8, now many users are still reluctant to XP, but it supports the onclick ah, I have tried under the FF, a little problem, but a switch IE8 under, tell you, a little reaction did not.

Then the multi-party search for information, the original select its event is registered on its own label, not onclick, but onchange, child tags on the lower version of the browser is not valid, but also not the formal standard.

<select onchange= "func () >
  <option value=" 0 "> Options one </option>
  <option value=" 1 "> Option two </option>
</select>

Well, here's the question again, what about the parameters I passed? How to receive Parameters
It's not a problem, jquery gives you the answer.

function func () {
 //Get the selected option tag
 var vs = $ (' Select Option:selected '). Val ();


Of course, the select here is best to add a ID to confuse, OK, problem solving, rose posture of wood there, haha ...

More about jquery-related content readers can view the site topics: "jquery form (form) Operation Tips Summary", "jquery Window Operation skills Summary", "jquery drag-and-drop effect and Skills summary", "jquery common Plug-ins and Usage summary", " Ajax Usage Summary in jquery, jquery table (table) Operation tips Summary, jquery extension tips, jquery Common classic effects summary, jquery animation and special effects usage summary and jquery selector Usage Summary

I hope this article will help you with the jquery program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.