ブログのリンクからカスタム スタイルを適用しようとしています。
<a>
この場合、ノードにスタイルを適用しないための直接ノードがあるかどうかを確認する必要がありますが<img>
、その方法がわかりません。
これは私のjs関数です
function linkify( selector ) {
var nodes = document.querySelectorAll( selector );
for( var i = 0, len = nodes.length; i < len; i++ ) {
var node = nodes[i];
var child=(node.firstElementChild||node.firstChild);
if( !node.className || !node.className.match( /roll/g )) {
// check that not it tag link and 'read more' button link
// TODO: Check that not have a img node!
if((node.getAttribute('rel') != 'tag') && (node.getAttribute('class') != 'more-link')) {
node.className += ' roll';
node.innerHTML = '<span data-title="'+ node.text +'">' + node.innerHTML + '</span>';
}
} } }
jQuery(document).ready(function( $ ) {
linkify('.post-content p a');
});