-3

I have 3 divs

<div class="content" data-id="Java"><button onclick=" onclick="alert('hi')">Java</button></div>
<div class="content" data-id="Php"><button onclick="alert('hi')">Php</button></div>
<div class="content" data-id="C++"><button onclick="alert('hi')">C++</button></div>

and I want to get the div with the data-id="Java" and change the onclick of the button inside of it in jQuery

um app101
  • 5
  • 4
  • While David's suggestion is right, you should show some effort in regards to the JS you attempted ;) – Adam Dec 19 '18 at 19:20
  • While the duplicate talks about name, name is an attribute, just like `data-id` – Taplar Dec 19 '18 at 19:20

1 Answers1

3
$('.content[data-id="Java"]') 

will select the element you want

$('.content[data-id="Java"] > button').hide()

will hide the button inside

Chris
  • 1,465
  • 1
  • 18
  • 36
  • It makes sense if you wish to refrain from making SO some sort of juvenile points contest. Votes should reflect perceived value to the community, and nothing more. Apparently your upvote was because you think the question has value, which is fine, but you didn't need to comment on it and make it something else. That's all I got. – isherwood Dec 19 '18 at 19:29