我正在尝试设置最大限制。当按下任何2个按钮时,必须有一个动作(其他按钮被禁用)。
这是wordpress中后置反应的代码。
我先尝试过这个链接
。- \*\*([^*]+)\*\*
但我不能。我如何计算点击次数并设置最大点击次数限制?
var regex = /(?:-\s+\*+)([\w\s\w]+)/g;
var str = `__**Cubone 100%**__Panama
Despawns @ 03:40:33am __**(29m 55s)**__
Weather Boost: **Clear :sunny:**
Level: 19 - IV: 100% (15/15/15) - CP: 5120
- **Rock Smash**
- **Dig**
**Map Info**: https://maps.google.com/?q=35.1224486753,-106.6278869713`;
var m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
console.log(m[1]);
}
此处还有php文件。
(function($) {
$(document).ready(function() {
$('#zuzu_viral_reactions li').click(function() {
var unreact = ($(this).hasClass("clicked") ? true : false);
var id = $(this).parent().data("postId") || $(this).parent().data("post-id");
var url = zvr_data.ajax_url;
var reaction = $(this).data().reaction;
$.post(url, { postid: id, action: 'zvr_react', reaction: reaction, unreact: unreact }, function(data) {
console.log("Ajax: " + data);
});
$(this).toggleClass("clicked");
var howMany = parseInt($(this).find('span').text());
if (howMany > 0) {
if ($(this).hasClass("clicked")) {
howMany += 1;
} else {
howMany -= 1;
}
} else {
howMany = 1;
}
$(this).find('span').text(howMany);
});
});
})(jQuery);
document.addEventListener("touchstart", function() {}, true);
if ('createTouch' in document) {
try {
var ignore = /:hover/;
for (var i = 0; i < document.styleSheets.length; i++) {
var sheet = document.styleSheets[i];
for (var j = sheet.cssRules.length - 1; j >= 0; j--) {
var rule = sheet.cssRules[j];
if (rule.type === CSSRule.STYLE_RULE && ignore.test(rule.selectorText)) {
sheet.deleteRule(j);
}
}
}
} catch (e) {}
}
答案 0 :(得分:0)
您可以通过jquery解决此问题,并通过以下代码获取最大长度事件
<label for="name">Input 1: maxlength=10</label>
<input type="text" maxlength="10" id="input-1" value="Allen"/>
$("#input-1").maxlength();
// get maxlength and other event
$("input").bind("update.maxlength", function(event, element, lastLength, length, maxLength, left){
console.log(event, element, lastLength, length, maxLength, left);
});