这是我需要获取backupURL值的代码..如何获得它?
var tem="<li><a class="selectBackupFromList" backupURL="http://localhost/3/wordpress/wp-content/infinitewp/backups/localhost-3-wordpress_installClone_full_2015-07-22_9521d628fe5b13281d87d2508e8112c3.zip"><span class="check rep_sprite_backup"></span><span class="bu_name">Backup for Clone</span><span class="bu_time rep_sprite_backup">Jul 22, 2015 @ 07:07pm</span><div class="clear-both"></div></a></li>";
如何获得它?
答案 0 :(得分:2)
将您的HTML字符串包装在jQuery中,然后您可以在其上使用jquery方法,就像它在DOM中一样。另外,请注意你的字符串是破碎的。对字符串使用单引号。
$(tem).find('.selectBackupFromList').attr('backupURL');
<强>演示强>
var tem = '<li><a class="selectBackupFromList " backupURL="http: //localhost/3/wordpress/wp-content/infinitewp/backups/localhost-3-wordpress_installClone_full_2015-07-22_9521d628fe5b13281d87d2508e8112c3.zip"><span class="check rep_sprite_backup"></span><span class="bu_name">Backup for Clone</span><span class="bu_time rep_sprite_backup">Jul 22, 2015 @ 07:07pm</span><div class="clear-both"></div></a></li>';
alert($(tem).find('.selectBackupFromList').attr('backupURL'));
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
&#13;