-2
関数内のmyUrlの前後にプラスの意味でお役立てください。関数内のhrefの+ in
+が正しく動作するかどうかは+で、正しく動作しないため、なぜ書籍が使用されたのですか?真である
<script type="text/javascript">
$(document).ready(function() {
$('a[href^="http://"]').each(function() {
var href = $(this).attr('href');
$(this).after(' {' + href + '}');
});
//$('a[href^="http://"').attr('target','_blank');
var myUrl = location.protocol + '//' + location.hostname;
$('a[href^="http://"], a[href^="https://"]').not('[href^="' + myUrl + '"]').attr('target', '_blank');
});
</script>
私はそれが '+'なしで動作するのではないかと疑います。 ['+' * string concatenation *](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Addition_())を実行します。 –
RTFMお願い、_ + _はJavaScript連結記号です。 –
間違いなく文法エラーです。 '+'なし –