Click here to Skip to main content
15,915,513 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionRe: Help Needed Pin
ZurdoDev23-Feb-16 9:02
professionalZurdoDev23-Feb-16 9:02 
QuestionJquery, changing span values with HTML5 data attr inside a div Pin
jkirkerx11-Feb-16 9:50
professionaljkirkerx11-Feb-16 9:50 
So I have this row that's a cart item. And inside the row are column divs with spans for values.
I manage to isolate the div row, and I'm trying to find the the spans and change the values.

I tried each, but it seems to grab all the elements, and not step through each one.
I'm stumped on this.

So my HTML looks like this, and I want to change the value of span data-qty attr and the inner html inside the span tag.
<div class="cartRecord" onclick="service_selectItem(17);" data-serviceid="1" data-cartid="17">
   <div class="cartQty">
       <span data-qty="7">7</span>
   </div>
   <div class="cartSKU" id="1000">
       <span>1000</span>   </div>
   <div class="cartDescription">
       <span>Diagnose and repair hardware or software</span>
   </div>
   <div class="cartPrice">
       <span>95.00</span>
   </div>
   <div class="cartTotal">
       <span data-total="665">665.00</span>
   </div>
</div>

This is what I have going, if my thoughts are way off track I'm open to suggestions.
success: function (data) {

    if (data !== null) {
    var dRecord = $('div.cartRecord[data-cartID="' + _cartID + '"]');
    if (dRecord !== null) {
        dRecord.each(function(index, element) {

            alert($(this).html()); // I get all the elements here, just wanted one

            // So this does work because I don't have a single element
            if ($(this).is('span')) {
                alert($(this).html());
                if ($(this).attr('data-qty')) {
                    alert($(this).html());
                    $(this).data('data-qty', data.Qty).html(data.Qty);
                }
            }
            // And of course this doesn't work
            if ($(this).is('span')) {
                alert($(this).html());
                if ($(this).attr('data-total')) {
                    alert($(this).html());
                    $(this).data('data-total', data.Total).html(data.Total);
                }
            }

        });

    }
}

AnswerRe: Jquery, changing span values with HTML5 data attr inside a div Pin
Richard Deeming11-Feb-16 10:17
mveRichard Deeming11-Feb-16 10:17 
GeneralRe: Jquery, changing span values with HTML5 data attr inside a div Pin
jkirkerx11-Feb-16 10:54
professionaljkirkerx11-Feb-16 10:54 
GeneralRe: Jquery, changing span values with HTML5 data attr inside a div Pin
Nathan Minier12-Feb-16 1:55
professionalNathan Minier12-Feb-16 1:55 
GeneralRe: Jquery, changing span values with HTML5 data attr inside a div Pin
jkirkerx12-Feb-16 6:30
professionaljkirkerx12-Feb-16 6:30 
GeneralRe: Jquery, changing span values with HTML5 data attr inside a div Pin
Nathan Minier12-Feb-16 7:03
professionalNathan Minier12-Feb-16 7:03 
GeneralRe: Jquery, changing span values with HTML5 data attr inside a div Pin
jkirkerx12-Feb-16 8:17
professionaljkirkerx12-Feb-16 8:17 
GeneralRe: Jquery, changing span values with HTML5 data attr inside a div Pin
Nathan Minier12-Feb-16 8:34
professionalNathan Minier12-Feb-16 8:34 
SuggestionRe: Jquery, changing span values with HTML5 data attr inside a div Pin
Richard Deeming12-Feb-16 8:41
mveRichard Deeming12-Feb-16 8:41 
GeneralRe: Jquery, changing span values with HTML5 data attr inside a div Pin
Nathan Minier12-Feb-16 8:57
professionalNathan Minier12-Feb-16 8:57 
GeneralRe: Jquery, changing span values with HTML5 data attr inside a div Pin
jkirkerx12-Feb-16 9:13
professionaljkirkerx12-Feb-16 9:13 
QuestionJTable Add New Record button Pin
Member 1231770910-Feb-16 0:25
Member 1231770910-Feb-16 0:25 
Questionhow to open the JTable Add new Record form in button click in another form Pin
Member 123177099-Feb-16 23:02
Member 123177099-Feb-16 23:02 
AnswerMy Vote of 1 Pin
Keith Barrow12-Feb-16 4:57
professionalKeith Barrow12-Feb-16 4:57 
Questionworking with showCreateForm() in jtable Pin
Member 123177099-Feb-16 19:23
Member 123177099-Feb-16 19:23 
AnswerRe: working with showCreateForm() in jtable Pin
F-ES Sitecore9-Feb-16 22:42
professionalF-ES Sitecore9-Feb-16 22:42 
GeneralRe: working with showCreateForm() in jtable Pin
Member 123177099-Feb-16 22:55
Member 123177099-Feb-16 22:55 
GeneralRe: working with showCreateForm() in jtable Pin
F-ES Sitecore9-Feb-16 22:58
professionalF-ES Sitecore9-Feb-16 22:58 
QuestionWhen IFrame load event is called ? Pin
Tridip Bhattacharjee4-Feb-16 1:45
professionalTridip Bhattacharjee4-Feb-16 1:45 
AnswerRe: When IFrame load event is called ? Pin
F-ES Sitecore9-Feb-16 22:26
professionalF-ES Sitecore9-Feb-16 22:26 
GeneralRe: When IFrame load event is called ? Pin
Tridip Bhattacharjee10-Feb-16 2:09
professionalTridip Bhattacharjee10-Feb-16 2:09 
GeneralRe: When IFrame load event is called ? Pin
F-ES Sitecore10-Feb-16 2:16
professionalF-ES Sitecore10-Feb-16 2:16 
GeneralRe: When IFrame load event is called ? Pin
Tridip Bhattacharjee10-Feb-16 20:44
professionalTridip Bhattacharjee10-Feb-16 20:44 
QuestionJavascript on dynamic gridview textboxs Pin
HGCoolPal2-Feb-16 2:48
HGCoolPal2-Feb-16 2:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.