S
S
SimpleShadow2015-11-03 17:01:12
JavaScript
SimpleShadow, 2015-11-03 17:01:12

How to reset all changes after a click function?

There is a code that makes changes to the h1 and img of the modal window.

$( "#example" ).click(function () {
   $( "#modal h1" ).html("Заголовок")
    $('#modal img').attr('src', '1d/main.png');
    ...
 });

How to reset all changes made in click to default state?
event.preventDefault()
does not work, but: removes click from the function altogether.
$( "#example" ).unbind( "click" );

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav Lyzlov, 2015-11-03
@SimpleShadow

No way. Write the code yourself.
Cancels browser actions.
unbind removes the click event handler from #example

H
holfza, 2015-11-03
@holfza

jsfiddle.net/vno8r4nk/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question