<div style="blah blah> <a href=”http://www.google.com”> is a red hyperlink,
but this text is all black</div>
我不想单独编辑内部的每个超链接。
答案 0 :(得分:0)
答案 1 :(得分:0)
为您的id=""
提供自己独有的class=""
属性,或者如果您有多个div,请为它们提供所有相同的<div class="className"><a href="http://foo">link</a></div>
.className a:link { color: red; }
值。
然后使用此规则:
<div id="identifier"><a href="http://foo">link</a></div>
#identifier a:link { color: red; }
或
// kind of usual
var sumRange = function (from, to, step) {
var i,
sum = from,
str = from;
for (i = from + step; i <= to; i += step) {
sum += i;
str += '+' + i;
};
str += '=' + sum;
return str;
};
// sum of elements in arithmetic progression
var sumRangeAP = function (from, to, step) {
var i,
n,
str = from;
n = ((to - from) / step) + 1;
for (i = from + step; i <= to; i += step) {
str += '+' + i;
};
str += '=' + ((from + to) / 2) * n;
return str;
};
// memory efficiency (not creating hell a lot of strings) together with some functional stuff
// on the other hand it looks like assignment operators (+, +=) win with .join in terms of speed sometimes
// in many cases, I think, you may not give a shit about whether you use this or that
var sumRangeME = function (from, to, step) {
var i,
sum = from,
str = [from];
for (i = from + step; i <= to; i += step) {
str.push(i);
};
return str.join('+') + '=' + str.reduce(function (prevVal, curVal) { return prevVal + curVal; });
};
console.log(sumRange(0,20,1));
console.log(sumRangeAP(0,20,1));
console.log(sumRangeME(0,20,1));
console.log(sumRange(1,21,1));
console.log(sumRangeAP(1,21,1));
console.log(sumRangeME(1,21,1));
console.log(sumRange(7,36,1));
console.log(sumRangeAP(7,36,1));
console.log(sumRangeME(7,36,1));
答案 2 :(得分:0)
您可以在文档就绪上添加jquery,并且如果您想要内联,则可以定位每个超链接。但最好的方法仍然是使用上面其他人所展示的css方法。
通过jquery来这里: $(&#39; div a&#39;)。css(&#39; color&#39;,&#39; red&#39;);