2013-09-10 43 views
1

如何從DOM中選擇突出顯示的值?

我試圖通過屬性值來選擇元素,因爲這樣的:

var item = jQuery("[name='directorSequence']"); 

但我不知道如何真正得到屬性"aria-valuenow="的價值......在此案件是4.

任何人都可以幫我一把嗎?

編輯 -

這是代碼的其餘部分:

detailRow.find(".directorsOrRecipients").kendoGrid({ 
    reorderable: true, 
    resizable: true, 
    dataSource: { 
     transport: { 
      read: { 
       url: "http://z/x/api/Awards/directors/" + awardTitleId, 
       type: "GET" 
      }, 
     }, 
     schema: { 
      model: { 
       id: "AwardDirectorId", 
       fields: { 
        "AwardDirectorId": { editable: false, type: "number", nullable: true }, 
        "namefirstlast": { editable: true, type: "string" }, 
        "directorsequence": { editable: true, type: "number", validation: { min: 1 } }, 
        "isonballot": { editable: true, type: "string" }, 
        "concatenation": { editable: true, type: "string" }, 
        "MoreNames": { editable: true, type: "number", validation: { min: 0 } }, 
       } 
      } 
     } 
    }, 
    columns: [ 
     { field: "AwardDirectorId", title: "Award Director Id", hidden: true }, 
     { field: "namefirstlast", title: "Name", editor: namesAutoComplete }, 
     { field: "directorsequence", title: "Director Sequence", format: "{0:n0}" }, 
     { field: "isonballot", title: "On ballot?", editor: onBallotDropDownEditor }, 
     { field: "concatenation", title: "Concatenation" }, 
     { field: "MoreNames", title: "More names?", format: "{0:n0}" }, 
     { command: ["edit"], title: " ", width: 100 }], 
    sortable: true, 
    sort: { field: "namefirstlast", dir: "desc" }, 
    editable: "inline", 
    toolbar: [{ name: "create", text: "Add New Director/Recipient" }], 
    save: function(e) 
    { 
     debugger; 

     $(document).ready(function() 
     { 
      debugger; 
      var item = jQuery("[name='directorSequence']"); 
      var x = item.attr("aria-valuenow"); 
     }); 



     $.ajax({ 
      url: "http://localhost/Take3/api/awards/directors", 
      type: "POST", 
      dataType: "json", 
      data: $.parseJSON(directorData) 
     }).done(function() 
     { 
      detailRow.find(".directorsOrRecipients").data("kendoGrid").refresh(); 
     }); 
    }, 
    edit: function() 
    { 
    } 
}); 
+0

風格顯示:無,挑選另一張照片。 –

回答

0

嘗試:

var item = jQuery("[name='directorSequence']"); 
item.attr("aria-valuenow"); 

的jsfiddle:http://jsfiddle.net/hescano/KmnAA/

+0

is item.attr(「aria-valuenow」);應該返回一個值?我對此沒有定義。 –

+0

@Rj。您必須確保此代碼位於$(document).ready()函數內。 –

+0

Hanlet,那仍然不起作用。請看看我更新的OP。查看AJAX功能。 –

0

使用attr()方法。

$('input[name=directorSequence]').attr('aria-valuenow') 

jquery API

+0

不!令人敬畏的顯示圖片。 –

+0

即時變得不明確。 –

+0

在jsfiddle中工作:http://jsfiddle.net/cZsdP/ –

相關問題