Solved

JQuery Syntax

Posted on 2015-02-14
1
31 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
1 Comment
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What if i make webbased alternative for MS Access 5 67
ASP.NET Content Page 3 27
Visual Studio npm 1 11
Why is initialize not a function? 8 21
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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…

856 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