3210を15.9
に変換するjQuery関数(またはまっすぐなjavascript)はありますか?jQuery HTML要素を削除しますがコンテンツを残します
基本的には<span>
タグを削除しますが、タグ内にあるものは残しておきます。
3210を15.9
に変換するjQuery関数(またはまっすぐなjavascript)はありますか?jQuery HTML要素を削除しますがコンテンツを残します
基本的には<span>
タグを削除しますが、タグ内にあるものは残しておきます。
を試してみてください。あなたのケースでは、我々は$(".emphasis").contents()
にそれを呼び出すと思いますので、あなたは、あなたがアンラップするノード上でそれを呼び出す:
$(".emphasis").contents().unwrap();
例:ときがあるため
// Show the content of the container prior to unwrapping
console.log("before unwrapping: " + $("#container").html());
// Unwrap
$(".emphasis").contents().unwrap();
// After unwrapping
console.log("after unwrapping: " + $("#container").html());
<div id="container">
<span class="emphasis">15.9</span>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
例範囲内の要素です:
// Show the content of the container prior to unwrapping
console.log("before unwrapping: " + $("#container").html());
// Unwrap
$(".emphasis").contents().unwrap();
// After unwrapping
console.log("after unwrapping: " + $("#container").html());
<div id="container">
<span class="emphasis"><em>15</em>.9</span>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
はJavaScript:
var content = document.getElementByClassName("emphasis").innerHTML;
https://api.jquery.com/unwrap/いくつかの使用であってもよいです。 –