Thanks Farmcow,
Yes, I know that I shouldn't do it.
But I have no choice. The CMS my customer is using is very outdated. It is running on NET. There are many other weird things happening with this CMS.
I personally use Joomla and I love it. When I compare Joomla and this outdated CMS is like...
I can add class to an element or tagname.
<script type="text/javascript">document.getElementById("menu").getElementsByTagName("li")[0].className = "first";
document.getElementById("sidebar").getElementsByTagName("ul")[1].getElementsByTagName("li")[0].className = "first";
</script>
Is there...
I want to add css to a current page in the main menu div by javascript.
Since I am using a old CMS, I am not do it by adding a code to html.
How can I do it?
What I am thinking is that if I use the title in head section the same as the menu, there must be way to do it?
Is it?
Code will be...
Thanks Dan,
I have another one in the same page.
<div id="sidebar">
<ul>
<li>
<h2>Undermeny</h2>
<ul class="leave">
<li><a href="#">Undersider 1</a></li>
<li><a href="#">Undersider 2</a></li>
<li><a href="#">Undersider 3</a></li>
<li><a href="#">Undersider 4</a></li>
<li><a...
Ok,
I put the following, but it still does not work.
var ul=document.getElementById('menu').getElementsByTagName('ul').getElementsByTagName('li')[0].className='first';
What am I doing wrong?
Thanks for your support.
Thank you for your reply.
I copied it in the external js and link it in the head.
But it still does not give a class to li.
My html codes is this.
<div id="header2">
<div id="menu">
<ul>
<li><a href="#">Forsiden</a></li>
<li><a href="#">Om oss</a></li>
<li><a...
Hi, please bear with me. Because I am a complete beginner to Javascript.
I need to insert a class to the first <li> tag in a certain <ul>.
My customer's CMS does not have to that function.
Could anyone tell me how to do it in Javascript please?
Thanks in advance.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.