how can get attributes of root element?

前端 未结 3 1519
余生分开走
余生分开走 2020-12-10 08:20


how can get attributes (rows) of root (data) element in jq

相关标签:
3条回答
  • 2020-12-10 08:47

    Try

    var records = $(xml).find("data").attr("rows");
    
    0 讨论(0)
  • 2020-12-10 08:54

    If it is a root node, use .filter() instead of .find().

    var records = $(xml).filter(":first").attr("rows");
    
    • http://api.jquery.com/filter/

    jQuery's .find() selects by searching inside the root nodes, while .filter() selects from among the root nodes.

    0 讨论(0)
  • This might not be working because it is having trouble finding the first element using the query you specified. This might be of some use to you:

    selecting root element in jquery

    After that .attr("rows") should work.

    0 讨论(0)
提交回复
热议问题