Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9054453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:41:43+00:00 2026-06-16T13:41:43+00:00

I have the following jquery code : function InitVoteContainer(voteContainer) { var _userVote = voteContainer.children(.storeUserVote).val();

  • 0

I have the following jquery code :

function InitVoteContainer(voteContainer) {

    var _userVote = voteContainer.children(".storeUserVote").val();
    var _userObjectId = voteContainer.children(".storeObjectId").val();
    var _userVoteKey = voteContainer.children(".storeVoteKey").val();
    var _UserAuth = voteContainer.children(".storeUserAuth").val();

    var _voteButtonUp = voteContainer.children("div[pid='btUp']");
    var _voteButtonDown = voteContainer.children("div[pid='btDown']");

    var upBtValue = 0;
    var downBtValue = 0;


        _voteButtonUp.attr("class", "upVote_inactive");
        _voteButtonDown.attr("class", "downVote_inactive");

        _voteButtonUp.prop("onclick", null);
        _voteButtonDown.prop("onclick", null);

}

The code will switch class on the upVote and downVote buttons. The code runs fine but the classes is never set? the question is why??

Edit 1:

Updates with some more code :

This jquery code runnes at dodument ready

function InitVoteControls() {

$("#mainPostList").find(".voteCon").each(function () {
    InitVoteContainer($(this));
});
}

And this is the HTML that the jquery is using :

<ul id="mainPostList" class="verticalList">
        @foreach (var postViewModel in Model.Posts)
        {
            <li>

<div class="postContainer">

<div class="voteCon">
        <input class="storeUserVote" type="hidden" value="@Model.UserVote" />
        <input class="storeObjectId" type="hidden" value="@Model.ObjectId" />
        <input class="storeVoteKey" type="hidden" value="@Model.VoteKey" />
        <input class="storeUserAuth" type="hidden" value="@Request.IsAuthenticated" />

        @if (!Request.IsAuthenticated)
        {
            <div pid="btUpVote" class="upVote"></div>
        }
        else
        {
            <div pid="btUpVote" class="upVote_inactive"></div>
        }

        <br style="clear:both;" />
        <div class="voteCountBox">
            @Html.Encode(Model.VoteBalance)
        </div>
        <br style="clear:both;" />

        @if (!Request.IsAuthenticated)
        {
            <div pid="btDownVote" class="downVote"></div>
        }
        else
        {
            <div pid="btDownVote" class="downVote_inactive"></div>
        }
</div>
</div>
</li>
        }
    </ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:41:44+00:00Added an answer on June 16, 2026 at 1:41 pm

    In your JavaScript you are selecting your button with

    voteContainer.children("div[pid='btUp']");
    

    which will return an emtpy jQuery object, since you have no div in your markup with the exact attribute pid='btUp'. You should use pid^='btUp' instead – or directly pid='btUpVote'.
    See this example or the W3C specification.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have the following JQuery code: $(document).ready(function () { var $containerHeight = $(window).height(); if
I have the following JQuery code: <script type=text/javascript> $(document).ready(function () { var $containerHeight =
I have the following jQuery code: $('.save').submit(function(e){ var formElement = $(this); var data =
I have the following jQuery code: var isUsernameAvailable = false; function CheckUsername(uname) { $.ajax({
I have the following code: jQuery(function ($) { var OSX = { container: null,
I have the following jquery code: $(document).delegate('.draggable','mousedown', function() { ... var connected_nodes = $(.linked-to
I have the following jquery slider code: $(function() { var select = $( #ppp
I have the following jQuery code: <script type=text/javascript> $(document).ready(function() { var color = ['none',
I have the following jQuery code: $(document).ready(function(){ var ac_config = { source: autocomplete-delta.php, select:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.