1. Home
  2. Docs
  3. JAVASCRIPT
  4. 字串
  5. find 找字串,indexOf

find 找字串,indexOf

var str1='<img src="img_girl.jpg" width="500" height="600" style="width: 32px; height: 32px;" >'
var n1 = str1.indexOf('style="');
var n2 = str1.indexOf('"',n1);
document.getElementById('powenko').innerHTML = n1+","+n2;

輸出:
49,55