Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

By using Jquery Div style wont change

$
0
0

Hi,

I'm experiencing some difficulty getting a div to show and cover up by setting its show in JQuery.

I have this div. (if it's not too much trouble take note of that this whole div is additionally within a Repeater control. I have settled repeaters.

<divid="cardfooter"class="cardfooter"><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><asp:RepeaterID="rptSocialData"runat="server"><HeaderTemplate></HeaderTemplate><ItemTemplate><buttonid="btnLike"type="button"class="btn btn-default btn-sm"><input id="hdnASID" type="hidden" runat="server" value='<%#Eval("ActivityStreamID") %>'/><spanclass="glyphicon glyphicon-thumbs-up"></span> Like</button><buttonid="btnComment"type="button"class="btn btn-default btn-sm"><input id="hdnASID2" type="hidden" runat="server" value='<%#Eval("ActivityStreamID") %>'/><spanclass="glyphicon glyphicon-comment"></span> Comment</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%#Eval("LikeCount") %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%#Eval("CommentCount") %></ItemTemplate><FooterTemplate></FooterTemplate></asp:Repeater><divclass="commentsDiv">
                this is the div</div></ContentTemplate></asp:UpdatePanel></div>

On the click of the btnComment button, I need to show the following div:

<divclass="commentsDiv">
    this is the div</div>

I have tried multiple solutions and the latest iteration of the JQuery is the following:

$(document).ready(function(){$('[id*=btnComment]').click(function(event){debugger;event.preventDefault();//preventing button's default behaviorvar ASID2 =$(this).find("input[type=hidden]").val();var element =$(this).parent();//get the update panel - Works! finding elementvar commentdiv = element.find("commentsDiv");// find commentsDiv in the update panel - Works! finding element
            commentdiv.css("color","red");// set the text to red as a test. NOT WORKING//alert(ASID2);});});

For some reason, the style is not applying to the div. I even tried attr("style", "color: red;");without success! Can anybody point me in the right direction?

Thank You

Hari


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>