这是我的html代码,我想改变
的风格<img src="linkremoved" style="
height:45px;
width:45px;
margin-right:10px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;">
我似乎无法解决这个问题。我需要用户脚本表格。
答案 0 :(得分:2)
使用纯JavaScript,最好添加一个id:
<img id="myImage" src="linkremoved" style="height:45px;width:45px;margin-right:10px;-webkit-border-radius: 50%;-moz-border-radius: 50%;border-radius: 50%;">
然后使用:
document.getElementById('myImage').style.height='50px';
如果您无法添加ID,则需要:
/**
* Get an image by it's src.
*
* Returns the first image matching the src
*/
function getImageBySrc( src ) {
var images = document.getElementsByTagName('img');
for (var i in images) {
if(images[i].getAttribute('src') == src) {
return images[i];
}
}
return null;
}
// useage
var myImage = getImageBySrc( 'linkremoved' );
myImage.style.height='50px';