2

Suppose I get 3 attributes:

var uid = $("#main_container").attr("uid");
var ticker = $("#main_container").attr("ticker");
var exchange = $("#main_container").attr("exchange");

I want to get the anchor tag that matches those 3 attributes. I'm not sure how to do that with regards to where to put the quotes. Would it be:

$('a[uid='+uid+'][ticker='+ticker+'][exchange='+exchange+']')

or

$('a[uid="'+uid+'"][ticker="'+ticker+'"][exchange="'+exchange+'"]')
5
  • 1
    $('a[uid="'+uid+'"][ticker="'+ticker+'"][exchange="'+exchange+'"]')?? Commented Mar 31, 2014 at 23:28
  • yes, fixing that error now. Is that the way to do it then? If yes, just add it as an answer and I'll give credit after testing :-) Commented Mar 31, 2014 at 23:29
  • 1
    jQuery Multiple Attribute Selector Commented Mar 31, 2014 at 23:32
  • @mdesdev, yes, the the confusion was how that would change if there are variables rather than text. where do the extra quotes go. Commented Mar 31, 2014 at 23:37
  • 1
    @user1357015 Ooh...always wrap single in double quotes or without mixing quotes when selecting half & half e.g. $('#someId'+variable) I'm always using singles except of course when I need mixing. Commented Mar 31, 2014 at 23:48

1 Answer 1

2

I think it is just that you have missed the parenthesis(used <> instead of ())

$('a[uid="' + uid + '"][ticker="' + ticker + '"][exchange="' + exchange + '"]')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.