/    Sign up×
Community /Pin to ProfileBookmark

How to make this function toggle

It is necessary that when you click “z-index” was added, and when you click again to delete.

$( ‘.projects-open’ ).click(function() {
$(“#projects-window”).parents().css({“z-index”: “9999”});
});

to post a comment
CSSJavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJun 12.2019 — Use a class to add the z-index and toggle it by jQuery:
$( '.projects-open' ).click(function() {
$("#projects-window").parents().toggleClass('has-z-idx');
});

.has-z-idx {
z-index: 9999;
}
Copy linkTweet thisAlerts:
@VITSUSAJun 12.2019 — You can do it 2 ways, one using css() method, the other by toggling a class on the element that includes a css rule that defines the z-index. Personally I prefer the toggling of classes, it just seems a lot easier to troubleshoot css.

http://api.jquery.com/css/

http://api.jquery.com/addClass/

http://api.jquery.com/removeClass/

http://api.jquery.com/toggleClass/
Copy linkTweet thisAlerts:
@seomsJun 12.2019 — college of mba in bangalore

https://www.kgi.edu.in/
×

Success!

Help @ethereal spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...