CSS目标选择器

时间:2015-08-31 15:22:19

标签: javascript jquery html css

有没有办法显示function getPointsFromStop(xScale, yScale, d, relative) { var last = null; var stops = d.stops.map(function (stop) { // special case: place-jfk, place-nqncy -> place-jfk, place-asmnl (at same time), place-nqncy // special case: place-nqncy, place-jfk -> place-nqncy, place-asmnl (at same time), place-jfk var result; if (last && last.stop === 'place-jfk' && stop.stop === 'place-nqncy') { result = [null, {stop: 'place-asmnl', time: last.time}, stop]; } else if (last && last.stop === 'place-nqncy' && stop.stop === 'place-jfk') { result = [{stop: 'place-asmnl', time: stop.time}, null, stop]; } else { result = [stop]; } last = stop; return result; }); var flattenedStops = _.flatten(stops); var startX = xScale(header[d.stops[0].stop + '|' + d.line][0]); var points = flattenedStops.map(function (stop) { if (!stop) { return null; } var y = yScale(stop.time) - yScale(flattenedStops[0].time); //console.log(stop.stop) var x = xScale(header[stop.stop + '|' + d.line][0]); if (relative) { x -= startX; } return [x, y]; }); return points; } function draw2(xScale, yScale, relative) { console.log("here") return function (d) { points = getPointsFromStop(xScale, yScale, d, relative); return points; }; } 代码“这是我的答案”当您点击锚标记时“点击我”只有p?我知道我可以在CSS标记之后添加p标记并使其正常工作,但我想知道是否有办法让它与下面的代码一起使用?

anchor

https://jsfiddle.net/vwep64bd/2/

1 个答案:

答案 0 :(得分:3)

这是一个仅限CSS的黑客文件,用于隐藏复选框来控制元素。这绝对似乎跨越了#34;应该"的界限,但当然,这是可能的。

更多阅读:https://css-tricks.com/the-checkbox-hack/



	li {
		list-style: none;
	}

	label.link {
		color: blue;
		text-decoration: underline;
		cursor: pointer;
	}

	div.info {
		display: none;
	}

	#toggle-1 {
		display: none;
	}

	#toggle-1:checked ~ div {
		display: block;
	}

<ul>
    <li>
        <div>
            <label class="link" for="toggle-1">Click Me</label>
        </div>
    </li>
    <input type="checkbox" id="toggle-1">
    <div class="info">
        <p>
            This is my answer
        </p>
    </div>
</ul>
&#13;
&#13;
&#13;