Do not run event on just one page

Asked

Viewed 27 times

2

I have the following code on every page

$( ":submit" ).click(function() {
		  $("#escondido").css("display","block");
		});

This code is in a Blabla.js file, and is included with php at the top of all pages of the site, but in just one page I do not want this event to occur, there is the possibility to disable it only on this page without having to remove Blabla.js

  • add the php tag, because it is easier to do it

2 answers

1

On the page I don’t want you to show the div.. I put on an event

$("#escondido").css("visibility","hidden");

So it "Executes" no more is visible.

  • is better if he gives a ("display", "none"), so the size of the item will not be accounted for

  • I tried to use the None display, but it didn’t work.. I decided to put the same visibility..

  • If size is getting in the way, you can use $("#escondido").remove(); that the element will be completely removed.

1

You can use Jquery’s Hide() function:

$( ":submit" ).click(function() { 
    $("#escondido").hide();
 });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id='escondido'>Escondido</div>

<input type='submit' value="Submit"/>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.