first, your code example is not complete and might throw an error, as the first function is not closed:
$(document).ready(function() {
$(".myadcss").click(function() {
$(this).hide(1000)
});
});
Now, only add the class "myadcss" to your ad banners. With that, the click function will only be triggered on your ad banners and not somewhere else.
Additionally, if you want to prevent hiding your banner, if some specific element was clicked, you can check the clicked elements class name and decide to abort your function in that case:
$(document).ready(function() {
$(".myadcss").click(function(event) {
if(event.target.classList.contains('specific')) {
return;
}
$(this).hide(1000)
});
});
.myadcss {
height: 200px;
width: 50px;
background: red;
}
.specific {
margin: 30px 5px;
height: 30px;
background: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>example</title>
</head>
<body>
<div class="myadcss">
Your banner text
<div class="specific"></div>
</div>
</body>
</html>
Check clicking the white area: Above JavaScript will check its class name and will abort executing further code by using the return statement.