0

I want to add multiple html attributes in html tag using .attr()but I'm getting the following error in my firebug console:

SyntaxError: missing : after property id
[Break On This Error]      
aria-selected: true,   
#PrizeBondSearch (line 149, col 22)

Here is the code that I tried:

$('ul.k-group').find('a[href="#' + url + '"]').addClass('k-state-selected k-state-focused').parent().attr({
    aria - selected: true,
    id: 'panelbar_pb_active'
});

I don't know why I'm getting this error or how to solve it. If there is any other better way, I will be glad to know of it.

3 Answers 3

3

I think it's the way you set the "aria-selected" - you should use quotes as it contains "-":

{
    "aria-selected": true,
    id: 'panelbar_pb_active'
}
Sign up to request clarification or add additional context in comments.

Comments

2

The correct synthax is:

$('ul.k-group').find('a[href="#' + url + '"]').addClass('k-state-selected k-state-focused').parent().attr({
          "aria-selected": true,
          id: 'panelbar_pb_active'

      });

See aria-selected wrapped in double-quotes (or could be single quotes).

Comments

1

You need to quote aria-selected because it has - in it.

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.