I wrote this code here:
$(document).ready(function(){ $(".button1").on(function() { var e1 = $(this).data("target1"); $(e1)toggleClass("rectangle1--open"); }) }); - That's right connected, but why it does not work ?? Tell me please!!!
I wrote this code here:
$(document).ready(function(){ $(".button1").on(function() { var e1 = $(this).data("target1"); $(e1)toggleClass("rectangle1--open"); }) }); - That's right connected, but why it does not work ?? Tell me please!!!
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
if you need to click on an element then $(".button1").click(...) . Inside the function there are also typos.
$(function(){ $(".button1").click(function() { var e1 = $(this).data("target1"); $(e1).toggleClass("rectangle1--open"); }) }); #t { width: 200px; height: 50px; border: 2px solid grey; text-align: center; line-height: 50px; } #t.rectangle1--open { background-color: orange; color: white; font-weight: bold; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a href="#" class="button1" data-target1="#t">тест</a> <div id="t">toggle</div> Source: https://ru.stackoverflow.com/questions/780645/
All Articles
$(".button1").on(function()what'son? There should be an event - Rostyslav Kuzmovych