前面要加载一个jquery库。
[removed]
var setNewsImg = function(obj){
$(obj).find('img').each(function(i){
var imgw = $(this).width();
var imgh = $(this).height();
var scale=1;
if(imgw>634){
scale = 634/imgw;
console.log(scale);
$(this).height(scale*imgh);
$(this).width(scale*imgw);
}
});