JavaScript
4
Вклад в тег
var values = [];
$("#workDesign label").on("click", function(){
var input = $(this).children("input");
var tag = $(this).text();
var i = values.indexOf(tag);
if (input.prop("checked")) {
input.parent().addClass("selected");
if (i==-1) values.push(tag);
//alert(tag);
} else {
if (i>-1) values.splice(i, 1);
input.parent().removeClass("selected");
}
$("#workDesignTags").val(values.join(", "));
});
<script type="text/javascript" src="http://vk.com/js/api/share.js?93" charset="windows-1251"></script>
<script>window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return t;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
t._e = [];
t.ready = function(f) {
t._e.push(f);
};
return t;
}(document, "script", "twitter-wjs"));</script>
<div id="main"></div>
var Component = React.createClass({
componentDidMount: function(){
this.refs.vk.innerHTML = VK.Share.button(false, {type: "round", text: "Сохранить"});
twttr.widgets.createShareButton(
'https://dev.twitter.com/',
this.refs.tw,
{
text: 'Hello World'
});
},
render: function(){
return (
<div>
<h4>Поделиться:</h4>
<div ref="vk"></div>
<div ref="tw"></div>
</div>
);
}
});
ReactDOM.render(<Component/>, document.getElementById("main"));