I am using the Squiz Matrix CMS system and integrating the Twitter Bootstrap into a page design. To make drop down menus I have notice that you need to place a <span class="caret"></span> inline within the anchor tag so that it shows a drop down arrow.
Problem is the system I am using automatically generates the menus based on the pages within a site so I can't manually insert the span tag.
I was wondering if there was a way to scan over the HTML content that is rendered onto a page within browser and check whether an unordered list has another unordered list nested within in it - then insert the span tag into the HTML if the condition is met.
I was thinking of using a jQuery function just before the closing body tag so the page HTML would render first before the script runs.
Sound like a possible thing to do with jQuery?
UPDATE: Put some jQuery code together to give it a test and it won't play ball with me.
Here is the HTML code:
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav">
        <li class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" href="http://testing.slq.qld.gov.au/qanzac100/about">About</a>
            <!-- start sub level list -->
            <ul class="dropdown-menu" role="menu">
                <li><a href="http://testing.slq.qld.gov.au/qanzac100/about/world-war-1-donations">World War 1 Donations</a></li>
                <li><a href="http://testing.slq.qld.gov.au/qanzac100/about/qanzac100">#qanzac100</a></li>
                <li><a href="http://testing.slq.qld.gov.au/qanzac100/about/onthisday">#onthisday</a></li>
            </ul>
            <!-- End sub level list -->
        </li>
    </ul>
</div>
For some weird reason the code editor won't let me insert the closing div.
Ok here is the jQuery code that sits at the bottom before closing the body tag:
<script type="text/javascript">
$('.navbar-nav > ul li').each(function(){    
    if($(this).has('ul')){
        $('.navbar-nav > ul li > a.dropdown-toggle').prepend('<span class="caret"></span>');
        alert("there is a child list");
    }    
});
</script>  
Is there something that I am doing wrong here?
 
     
     
    