1
I’m trying to highlight a text with the event click and then "slip" on the second click, I took the hint of a code that I had already seen on codepen , I am passing two functions to the event click, but only the second works, code:
$('.texto').click(function() {
alert(1);
}, function() {
alert(2);
}
);
Only the Alert(2), why does this happen?
But the function
click
accepts only one function Handler at a time. If two parameters are passed, the first one will beeventData
and only the second will be thehandler
See the documentation. What exactly do you intend to do?– Woss
I want to highlight the text, would use the css() function, with text-Decoration, take a look at the example I put of codepen that uses this concept, or I left something unnoticed rs
– Thiago
Yes. In the example it uses the function
hover
which in fact has two functions,handlerIn
andhandlerOut
. Theclick
doesn’t work that way.– Woss
Ah, I see, what would be the best way to do that?
– Thiago
Will be the element
.texto
integer that will be marked or some text that is selected?– Woss
The same text element.
– Thiago
It would look something like this: https://jsfiddle.net/acwoss/1j9qcfs1/ ?
– Woss
That’s right, thank you!
– Thiago
Is there an event like this toggle? because I also want to use ajax, to change the status, it would be something like 0 and 1, only dynamically.
– Thiago
How so event like
toggle
?– Woss
Toggle between clicks, for example, the application would be a "list of things to do", on the first click, text is underlined, with ajax I change the status to 1, and on the second click, it would be "unlinked" and ajax would change the status to 0...
– Thiago
Let’s go continue this discussion in chat.
– Woss