Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change element depending on current page using jQuery

Posted on 2013-01-06
5
Medium Priority
?
300 Views
Last Modified: 2013-01-07
Hi guys,

I am trying to figure out a way to change the position of a css element depending on the page it is being viewed using jQuery. I must stress that I am very new to jQuery and would like to know how I can manipulate the DOM for my site.

I need something like this:

if element is on homepage {position:relative} else {position:fixed};

I really not sure how to do this and would be grateful for some assistance please...
0
Comment
Question by:rafique12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 2000 total points
ID: 38748606
Why would you not just have two classes in your stylesheet; one with position:absolute, and one with position:relative?  Then on the server you generate the element with the class it needs.  You know what page you are sending, so you do it when you generate the page. instead of screwing around with client side scripting.

Cd&
0
 

Author Comment

by:rafique12
ID: 38748627
You have a point, a very good point!

I was trying to avoid duplicating the template file for shopping cart sidebar (Magento). I currently have it showing on the product view page with position relative. I also have it showing on the checkout page where I would like it to be fixed so its always visible when scrolling down the page....
0
 

Author Comment

by:rafique12
ID: 38748906
Its only fair. Thanks for the nudge!
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38749370
Why the C if my response did not help then just have the Q deleted and indicate you need something additional.  It is really quite insulting that I am the only one to respond to your question and you throw the lowest possible grade at me, without any indication of a reason for it.

Cd&
0
 

Author Comment

by:rafique12
ID: 38749629
You shouldn't be insulted, its an average answer to a question that had asked for something more specific. I preferred to award you the points instead of deleting the question as I thought that would have been an insult... Seems I was damned if I did and damned because I didn't.

Is there a way to change the grade?
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question