I have a a div section which within it stores a hidden Id value. I am trying to access this in jquery but can't find a way. Could someone point me in the right direction?:

<apex:pageBlockSection rendered="{!c.Time_Slot__c == '6:00 AM - 8:00 AM'}" title="6 AM" collapsible="false">
    <div id="firstSlot" class="dragCell">
        <input type="hidden" value="{!c.Id}" styleClass="inputHidden-1"/>


        classes: {
            'ui-droppable-hover': 'highlight'
        drop: handleDropEvent,
        tolerance: "pointer",
        hoverClass: 'highlight',
        drop: function(ev, ui){
            var item = ui.draggable;
            if (!ui.draggable.closest('.dragCell').length) item = item.draggable();
            this.innerHTML = '';
            item.css({ top: 0, left: 0 }).appendTo(this);
            $("[id$='saveButton']").attr("disabled", false);
            var theValue = ui.draggable.closest('.inputHidden-1');
            var int = ui.draggable.closest('.dragCell').children(":first").toggleClass(".inputHidden-1");
            console.log(theValue); //does not give right value
            console.log(int); //does not give right value
  • $(".inputHidden-1") doesn't work? Feb 16 '17 at 17:21
  • @JesseMilburn no it doesn't work. doing $(".inputHidden-1").text() returns blank
    – saint
    Feb 16 '17 at 17:32
  • 2
    ahh, your input isn't an apex element. Change styleClass to class. Feb 16 '17 at 17:47
  • Given that you are using standard HTML elements, I have to agree this question belongs on Stack Overflow.
    – Adrian Larson
    Feb 16 '17 at 19:25

Your input has an apex styleClass in the markup, but is an HTML input.

Change this:

<input type="hidden" value="{!c.Id}" styleClass="inputHidden-1"/>

To this:

<input type="hidden" value="{!c.Id}" class="inputHidden-1"/>

Make it easy on yourself, give it an Id

<input id="myField" type="hidden" value="{!c.Id}" class="inputHidden-1"/>

The get the value (not text)

  • I have multiple hidden fields so will need to access dynamically.. thats my main issue
    – saint
    Feb 16 '17 at 17:51
  • @saint - Then use the class and a $.each with the appropriate selector. The direct answer to your question is to use .val() not text. Finding the appropriate selector is not on topic here as there are other SE sites that deal with jQuery/Javascript
    – Eric
    Feb 16 '17 at 17:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.