How to apply css style on the list of div by defending on the class name using javascript

Tags: javascript,jquery,css

Problem :

I got list of li tag that have 2 kinds of class name coding and design. The result that i want is if the li is design the post-link is display block and the site-link is display none while coding class name will have opposite effect. I store the li class into array then the condition will loop to find out what li tag have class name of design and coding. The result is the condition only read the last element of the array. Can you help me on this... sorry not good in asking question in english.


<li class="Design">
    <a class="post-link"></a>
    <a class="site-link"></a>
<li class="Design">
    <a class="post-link"></a>
    <a class="site-link"></a>
<li class="Coding">
    <a class="post-link"></a>
    <a class="site-link"></a>

var workArray = [];
var $work = jQuery('.slide-container li');
var $workClass = $work.attr('class');

        for(i = 0; i < workArray.length; i++){

Solution :


.Design .site-link {
   display: none;

.Coding .post-link {
   display: none;

and let the browser does the array/traverse push/pop by itself ;)

    CSS Howto..

    How to remove curved line in HTML/CSS

    CSS: how to calculate margin inside a div for a fluid layout

    How to put Facebook and Twitter buttons next to each other?

    how to underline a letter of button caption in vaadin?

    How do I disable warnings from Aspx files (HTML,CSS)

    How to make gridview in scrollable?

    How to use conditional CSS for IE browser in drupal6?

    How do I know when is the right moment to stop using a specific css vendor-prefix?

    More CSS woes: how to stack divs inside another div, and have them all behave?

    Show content only in printing page not in browser page using CSS or javascript

    How to change the CSS after image lazy loading (jQuery)? [closed]

    How to make a div fade on hover?

    How to set a css class of the widget type with Symfony2

    how do you create tags like stackoverflow with text styling

    How To Apply jQuery CSS Selector

    How to control the CSS on an Active/Focused button in Foundation 5 [RESOLVED]

    How to make div disappear when clicking outside?

    How to get actual (not original) height of a CSS-rotated element

    How to have jquery add a panel inside a panel in Bootstrap v3

    How to create centered image slideshow behind website content

    How to position an element at the TOP LEFT corner of a page using CSS?

    How can I divide the screen to these divs in css?

    How to add border between td's in which are in different tr's?

    how to change li last anchor color

    On a web page how do I display a label that changes to a drop down box on hover

    Using javascript to show html on every page except one page

    how to add a different text box in input text type

    How to achieve following graphics via css

    How to change color of caret when drop down button is hovered

    How show button hovering above an image or pressing over it? [closed]