Solved

Change element depending on current page using jQuery

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xjs: how to get sum of value in for loop 2 19
Explain this javascript function to me 2 29
AJAX Wordpress Not Reading Variable 2 31
Search Item in Table 2 23
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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 …

828 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