Click here to Skip to main content
16,004,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
I have
<div id='cssmenu'>
<ul>
 <li class= 'has-sub'><a href=store.aspx?id=dLYTWvt8EsHOq7Ps2wJA9A%3d%3d&digest=tNy7s/jOrynR4pvMVN6d6Q==><span>Armed Combat</span></a> <ul>
 <li class= 'has-sub'><a href=store.aspx?id=xEDEzZWDRkX8%2fbXoMX2pSQ%3d%3d&digest=tNy7s/jOrynR4pvMVN6d6Q==><span>Armed Combat 1-2</span></a><ul>
 <li class= 'active'><a href=store.aspx?id=TxlSRrnSZ6HDgj%2b2ZSxRhg%3d%3d&digest=tNy7s/jOrynR4pvMVN6d6Q==><span>Dance -1</span></a></li>


and in reqid
var reqid = "<%=Request["id"]%>";


in reqid i will get urlencoded based on menu selection

My jquery code here
$(function () {
                var str = $("#cssmenu").find('li').find('a').attr('href');

                if ($(str).has(reqid)) {

                   var str2 = $("#cssmenu").find('li').find('a').text();
                    $('#selectedmenuitem').html(str2);
                }
            })


if the href attribute encoded url contains selected menu item encodedurl i want to get the matched url .text();
to the #selectedmenuitem label id .

I checked with contains ,has ,am not getting .please suggest me what are other passibilites for this
Posted
Updated 28-Nov-13 18:19pm
v2
Comments
JoCodes 29-Nov-13 4:31am    
Before you check the condition you need to decode the href value

Hi

Try this code...


XML
<script type="text/javascript">
        $(function () {

            var reqid = '<%=Request["id"]%>';
            $("#cssmenu li a").each(function () {

                if ($(this).attr('href') == reqid) {
                    $('#selectedmenuitem').html($(this).text());
                }


            });

        })
    </script>
 
Share this answer
 
Comments
karthik mushyam 29-Nov-13 3:57am    
href contains half of reqid encodedurl .If both are same i can use ur code but reqid is part of href.
karthik mushyam 29-Nov-13 3:59am    
Please can u check this once again ...am fighting with this from yesterday morning
Karthik_Mahalingam 29-Nov-13 5:00am    
try this..

$(function () {


var reqid = '<%=Request["id"]%>';
$("#cssmenu li a").each(function () {

if ($(this).attr('href').indexOf(reqid) != -1) {
$('#selectedmenuitem').html($(this).text());
}
});

})
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900