Answer the question
In order to leave comments, you need to log in
How to change styles for an element only on a page with a specific URL?
Good afternoon %username%
The question has matured, how can I change the styles of an element only on a page with a specific URL
I thought at first, try to refer to the parent selector and get by with pure CSS , using adjacent and child selectors + > but unfortunately this option cannot be implemented (
In Due to the lack of skill in writing scripts in JS (jQuery), I wanted to turn to you dear friends.
Please help me write a simple script with one of these options and the following logic:
если url страницы http://sitename/pages/page1/
1 вариант: тогда к элементу с классом "obj" добавить стиль color: red;
2 вариант: тогда к элементу с классом "obj" добавить класс "obj2"
Answer the question
In order to leave comments, you need to log in
https://jsfiddle.net/fhjv0bcu/1/
Add the special class to the id=item object depending on the url.
ps You can't do web if you don't master js. (not jquery, but js)
c jquery
1)
if ( location.pathname == '/pages/page1/' ) {
$('.obj').css('color', 'red');
}
if ( location.pathname == '/pages/page1/' ) {
$('.obj').addClass('obj2');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question