私はいくつかの非常に厳しいパックエンドの制限内で作業しており、彼の要求に容赦のないクライアントがいるため、.jsでやりたくないことをすることを余儀なくされています。
とにかく、ここに行きます。
お客様のレビューがあります。それらのレビューの最後に、「- 米国」または「- オーストラリア」があります。基本的に、すべてのレビューの最後に「-[場所]」があります。その文字列をレビュー テキストから取り出して、スパンに挿入する必要があります。私はjQueryを使用しているので、それに固執したいと思います。
各レビューを実行して必要な場所に挿入する方法を整理しましたが、各レビューからその文字列を取得して各レビューから削除する方法がわかりません. それは私が本当に助けを借りることができるところです。
テキスト例:
<div class="v2_review-content">
<h4>These earplugs are unbelievable!</h4>
<p class="v2_review-text">These are the only earplugs I have ever used that completely block out annoying sounds. I use them at night due to the fact I am an extremely light sleeper and the slightest noise will wake me up. These actually stick to the ear in an airtight suction and do not come out at all until I pull them off in the morning. These are as close to the perfect earplug as you can get! - United States</p>
<p class="v2_review-author">Jimmy, March 06, 2013</p>
</div>
それが役立つ場合は、underscore.jsも利用できます。