substring()
사용 indexof()
이 작업을 수행 할 수 있습니다.
str = '<a href = "#homecoupon" class ="current">COUPONS</a>';
// get rid of </a> assuming the string always ends with it
var x = str.substring(0,str.length-4);
// use the fixed part to get the value you want
alert(x.substring(x.indexOf('class ="current">')+17))
또는
str = '<a href = "#homecoupon" class ="current">COUPONS</a>';
fixedPart = 'class ="current">';
// use the fixed part to get the value you want assuming str always ends with </a>
alert(str.substring(str.indexOf(fixedPart)+fixedPart.length, str.length-4))
당신은 웹 사이트를 긁어 나 웹 사이트의이 부분입니까? – nico
두 답변이 모두 도움이 될 것입니다. 그 줄을 작은 따옴표로 묶고 마지막에 광고 세미콜론을 추가하십시오. 그렇지 않으면 지옥에 유효한 구문이 될 방법이 없습니다. – amenadiel