我正试图从HTML标题中抓取某些字符 - 特别是分数(这是动态的)。在这种情况下'9.1'。
我应该使用什么Jquery函数?
<div class="average_score" style="background-position:-9020.0px 0; background
-image: url('//cdn.images.reevoo.com/en-GB/scores/standard/transparent/110/
sprite.png');" title="Score is 9.1 out of 10 from 154 reviews"></div>
答案 0 :(得分:0)
$(document).ready(function(){
var title = ($(".average_score").attr("title")).split(' ');
console.log(title[2]);
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="average_score" style="background-position:-9020.0px 0; background
-image: url('//cdn.images.reevoo.com/en-GB/scores/standard/transparent/110/
sprite.png');" title="Score is 9.1 out of 10 from 154 reviews"></div>
&#13;