Adding date tags to the button with jquery

2

I need to add tags data to my button when I hover over it, I already get the mouse hover move now I need to add the tags , which are:

data-trigger="hover" 
data-toggle="popover"
data-placement="bottom"
data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
data-original-title="Popover Title"

Then my button at the end should look like this:

<button class="btn btn-primary" data-trigger="hover" data-toggle="popover"
        data-placement="bottom"
        data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
        title="" data-original-title="Popover Title">
   Meu botão
</button>

The$(this)accessesthebutton'sgift.ButIneedtoputthelinkintagspanasintheimageabove.

Mycodelookslikethis:

eventMouseover:function(event,jsEvent,view){$(jsEvent).attr("data-trigger","hover");
  $(this).attr("data-toggle","popover");
  $(this).attr("data-placement","bottom");
  $(this).attr("data-content","Vivamus sagittis lacus vel augue laoreet rutrum faucibus.");
  $(this).attr("ata-original-title","Popover Title");
}

I need the attributes to be added to the child of $(this) because $(this) is tag a , and what you need to receive is the child of a , span

    
asked by anonymous 11.01.2017 / 00:18

2 answers

2

An alternative without using attr would be data() of JQuery itself.

According to the documentation:

  

11.01.2017 / 00:39
2

Would that be?

$("#botao").on("mouseover",function(){
  $(this).attr("data-trigger","hover");
 $(this).attr("data-toggle","popover");
 $(this).attr("data-placement","bottom");
 $(this).attr("data-content","Vivamus sagittis lacus vel augue laoreet rutrum faucibus.");
$(this).attr("ata-original-title","Popover Title");


});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><buttonclass="btn btn-primary" id="botao">
Passe o mouse
</button>
    
11.01.2017 / 00:23