?
Solved

JQuery Syntax

Posted on 2015-02-14
1
Medium Priority
?
37 Views
Last Modified: 2015-03-03
In JQuery, is there a way to write, "IF a Select Name Contains"?

I have the following:
var deduc = $('select[name="item_options[product_deductible]"]').val();

I would like to have:
var deduc = $('select[name="IF NAME CONTAINS - product_deductible"]').val();
0
Comment
Question by:rgranlund
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 40610041
use the wildcard (*) character in the selector:

$("[name*='product_deductible']")

Open in new window


Obviously if you use this, it may match more than one element and only return the first, so consider that when you design your app.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question