Solved

Change element depending on current page using jQuery

Posted on 2013-01-06
5
296 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 500 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
CSS Odd/Even Confusion 2 40
Json and ajax javascript 24 23
Error just appeared 3 23
Firefox CSS Help. 1 9
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

734 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