Click here to Skip to main content
15,904,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi every one i want to just hide href which have NO Image here is my website link where i want to do this..

http://www.minatocars.com/stockdetails.aspx?ID=996[^]

i have Done this with jSFiddle but want to implement this in my website but dont figur it out why this is not working on my site

http://jsfiddle.net/7cnQN/96/[^]

What i am trying to do is below on jQuery pageLoad event
but this is not functioning even if i put alert function of javascript inside if condition is also not working! i think i have refance path issue or may be i am trying to access worng

XML
<script type="text/javascript">

    function pageLoad(){
        $('div#right_contan#<%=FormView1.ClientID %> div.img_slider_car p.thumbs a').each(function(index) {

            if ($('a')[index].href == 'http://localhost:37245/NewPeaceAuto - Steer_Well/WebStock_Images/noimage.png') {
                $(this).hide();
            }
            else {
                $(this).show();

            }
        });
    };
    </script>


javascript Source in Master Page

XML
<asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Path="~/js/jquery.js" />
            <asp:ScriptReference Path="~/js/jquery-1.4.2.js" />
            <asp:ScriptReference Path="~/js/jquery.min.js" />
            <asp:ScriptReference Path="~/js/jquery-ui-1.8.18.custom.min.js" />
            <asp:ScriptReference Path="~/js/jquery.tools.min.js" />
            <asp:ScriptReference Path="~/js/custom.js" />
            <asp:ScriptReference Path="~/js/hoverIntent.js" />
            <asp:ScriptReference Path="~/js/menu.js" />
        </Scripts>
    </asp:ScriptManager>


Custom User Control Code inside page.aspx (i am getting images in css class thumbs)

XML
<div id="right_contan">
<asp:FormView ID="FormView1" runat="server" DataSourceID="odsSTOCK">
        <ItemTemplate>
            <div class="img_slider_car" style="width:670px;">
                <div>
                    <img src="images/Detail_Car_Img.png" />
                    <p class="CarDetail_headertext">
                        <%#Eval("make")%>
                        &nbsp;&nbsp;
                        <%#Eval("model_description")%>
                        &nbsp;&nbsp;<%#Eval("MODEL")%></p>
                </div>
                <div class="CarDetail_Right">
                    <p style="margin-left: 8px; margin-top: 0;">
                        <a href="Negotiation.aspx?id=<%#Eval("ID")%>">
                            <input id="btnNego" value="Negotiation" type="button" class="button_3" style="width:100px"/>
                        </a><a href="EnquiryForm.aspx?id=<%#Eval("ID")%>">
                            <input id="btnEnquiry" value="Enquiry" type="button" class="button_1" />
                    </p>
                    <ul>
                        <li><a href="">Chasiss: <b>
                            <%#Eval("chassis_no")%>
                        </b></a></li>
                        <li><a href="">Body Type:<b>
                            <%#Eval("make_category")%>
                        </b></a></li>
                        <li><a href="">Model Year: <b>
                            <%#Eval("MODEL")%>
                        </b></a></li>
                        <li><a href="">Trans: <b>
                            <%#Eval("Transmission")%>
                        </b></a></li>
                        <li><a href="">Color: <b>
                            <%#Eval("COLOR")%>
                        </b></a></li>
                        <li><a href="">Mileage: <b>
                            <%#Eval("mileage")%>
                        </b></a></li>
                        <li><a href="">Grade: <b>
                            <%#Eval("veh_grade")%>
                        </b></a></li>
                        <li><a href="">Fuel Type: <b>
                            <%#Eval("fuel_type")%>
                        </b></a></li>
                    </ul>
                </div>

                <p style="padding-top:21px;" >
                    <img id="largeImg" src="<%=appdata.Stk_Img_Path %><%#Eval("IMAGE1")%>" alt="Large image"  width="120px" height="90px" />
                </p>
                <p class="thumbs" style="width: 672px;">
                    <a href="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE1") %>" title="<%# Eval("make") %>  <%#Eval("model_description")%>">
                        <img src="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE1") %>" /></a> <a href="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE2") %>"
                            title="<%# Eval("make") %>  <%#Eval("model_description")%>">
                            <img src="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE2") %>" /></a> <a href="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE3") %>"
                                title="<%# Eval("make") %><%#Eval("model_description")%>">
                                <img src="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE3") %>" /></a> <a href="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE4") %>"
                                    title="<%# Eval("make") %><%#Eval("model_description")%>">
                                    <img src="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE4") %>" /></a> <a href="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE5") %>"
                                        title="<%# Eval("make") %><%#Eval("model_description")%>">
                                        <img src="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE5") %>" /></a> <a href="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE6") %>"
                                            title="<%# Eval("make") %><%#Eval("model_description")%>">
                                            <img src="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE6") %>" /></a>
                    <a href="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE7") %>" title="<%# Eval("make") %>  <%#Eval("model_description")%>">
                        <img src="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE7") %>" /></a> <a href="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE8") %>"
                            title="<%# Eval("make") %>  <%#Eval("model_description")%>">
                            <img src="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE8") %>" /></a> <a href="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE9") %>"
                                title="<%# Eval("make") %>  <%#Eval("model_description")%>">
                                <img src="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE9") %>" /></a> <a href="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE10") %>"
                                    title="<%# Eval("make") %>  <%#Eval("model_description")%>">
                                    <img src="<%=appdata.Stk_Img_Path %><%# Eval("IMAGE10") %>" /></a>
                </p>
            </div>

        </ItemTemplate>
    </asp:FormView>
</div>


plz suggest me the better way to do this
Posted
Updated 13-Nov-13 0:10am
v4
Comments
fDrg 13-Nov-13 6:43am    
have you tried using
$(document).ready(){function (){

//On page load

});

Your selector is wrong

$("div#right_contan#<%=FormView1.ClientID %> div.img_slider_car p.thumbs a")

will be something like

HTML
<div id="right_contan"> <!--with a second id = formName-->
   <div class="img_slider_car"> 
    <p class="thumbs"> 
     <a></a>
    </p>
   </div>
</div>


wich is not valid

but, based on you jsfiddle example
the code you need is

JavaScript
$("a[href='http://www.abumousamotors.com/WebStock_Images/noimage.png']").hide()

or
JavaScript
$("a[href$='noimage.png']").hide()


if you need somethig more specific

JavaScript
$("#right_contan .img_slider_car p.thumbs a[href$='noimage.png']").hide()


Hope it helps
 
Share this answer
 
v2
Comments
anglo0072 14-Nov-13 6:33am    
Thankx Moykn it`s works Perfectly i need more specific, i just use this
$("#right_contan .img_slider_car p.thumbs a[href$='noimage.png']").hide()
and it`s working properly

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