[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Change element depending on current page using jQuery

Posted on 2013-01-06
5
Medium Priority
?
301 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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

831 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