Reputation:
I am using the following code,
<div>
<ul>
<li class="hide">Code 1</li>
<li class="hide">Code 2</li>
<li class="hide">Code 3</li>
<li class="hide">Code 4</li>
<li class="hide">Code 5</li>
<li class="hide">Code 6</li>
<li class="hide">Code 7</li>
<li class="hide">Code 8</li>
</ul>
</div>
$(document).ready(function() {
$(".hide").click(function(e) {
$(this).toggleClass("hideit");
});
});
ul li.show {
list-style: inside;
padding-left: 15px;
cursor: pointer;
height:16px;
}
ul li.hideit {
list-style: none;
list-style-image: none;
padding-left: 35px;
cursor: pointer;
}
But the issue is when i click it, the text goes to the right and click on again it comes to its same position
I am trying the way is when i click the li the list-style should come to none, but the text should not move
I am checking with IE7+ browsers and all OPera, Safari, FF, Chrome
Regards
Upvotes: 0
Views: 77
Reputation: 15860
When you click, a class is added to the element! hideit
.
And for that class, you're using
padding-left: 35px;
And on a re-click, the class is removed and indirectly the padding is removed from the element!
This is causing the issue, remove it! And your issue will be fixed!
Once you remove it, the element won't move any further!
Upvotes: 0
Reputation: 38262
Just remove padding
from your class hideit
:
ul li.hideit {
list-style: none;
list-style-image: none;
/*padding-left: 35px; Remove this*/
cursor: pointer;
}
The demo http://jsfiddle.net/wHdYH/1/
Upvotes: 2
Reputation: 388446
Remove the padding from hide-it
ul li.hideit {
list-style: none;
list-style-image: none;
cursor: pointer;
}
Demo: Fiddle
Upvotes: 3