0

I need to add target="blank" to the a tag with li data-id="232"

<li class="" data-id="232"> <a href="new.html"> New Page </a> </li> 

using jQuery.

1
  • 4
    It should be jQuery('li[data-id="232"] a').prop('target', '_blank') Commented Oct 30, 2017 at 6:45

1 Answer 1

2

You can use .attr with the following jQuery selector:

$('li[data-id="232"] a').attr('target', '_blank') 
Sign up to request clarification or add additional context in comments.

1 Comment

target is a property of Anchor not li element

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.