在我的Angularjs应用程序中,我正在使用此https://github.com/vinaygopinath/ngMeta.
<title ng-bind="ngMeta.title"></title>
<meta property="og:title" content="{{ngMeta.title}}" />
<meta property="og:description" content="{{ngMeta.description}}" />
Run Code Online (Sandbox Code Playgroud)
我的控制器代码是
app.controller('controller1',function($scope, $location , $http , $routeParams, ngMeta, $route){
$scope.$route = $route;
ngMeta.setTitle('site title');
ngMeta.setTag('description', 'this is description');
ngMeta.setTag('keywords', 'tag1, tsg2, tag3');
});
Run Code Online (Sandbox Code Playgroud)
在页面加载一切正常,但谷歌显示{{ngMeta.description}} {{ngMeta.title}}这样任何帮助来解决这个问题.
我的HTML是:
<p><ins data-id="1">111</ins><ins data-id="2">222</ins></p>
Run Code Online (Sandbox Code Playgroud)
此代码的输出是:
如果我双击该单词,它会选择完整的单词,如下所示:
但我想根据INS标签选择字母 data-id
例如: - 如果我双击111我想要只选择111这样:
如何修改默认的双击选择到JavaScript选择?
我尝试了以下代码:
var containerid = $(e.currentTarget);
if (window.getSelection) {
var range = document.createRange();
range.selectNode(containerid);
var sel = window.getSelection()
sel.removeAllRanges();
sel.addRange(range);
}
Run Code Online (Sandbox Code Playgroud)
但它没有按预期工作.
const ref = useRef()
React.Children.map(this.props.children, (element) => {
React.cloneElement(element, {
innerRef: node => ref,
})
})
Run Code Online (Sandbox Code Playgroud)
这里元素是一个组件
像下面这样
const newComponent = forwardRef(({children, ...otherprops}, ref){
return (
<div {...otherprops} ref={otherprops.innerRef}>
{children}
</div>
)
})
Run Code Online (Sandbox Code Playgroud)
得到ref是null在 forwardRef ...
可重现的示例:- https://codesandbox.io/s/forward-ref-cloneelement-1msjp
<button class="fbutton btn pull-right filterevents " id="one" >School Events</button>
<button class="fbutton btn pull-right filterevents" id="two" >Zone Events</button>
<button class="fbutton btn pull-right filterevents" id="three" >My Events</button>
Run Code Online (Sandbox Code Playgroud)
我需要在特定按钮onClick上添加"selected"类.
我的代码是
$("#one").click(function(e) {
$(this).addClass("fcurrent");
$("#two").removeClass("fcurrent");
$("#three").removeClass("fcurrent");
});
Run Code Online (Sandbox Code Playgroud)
如果我使用而不是id来上课,如下
$(".fbutton").click(function(e) {
$(this).addClass("fcurrent");
});
Run Code Online (Sandbox Code Playgroud)
那么如何将fcurrent类删除到另外两个按钮
我正在尝试创建一个小表单,提交一个data-ida li并传递一个值onclick li.这是我到目前为止所做的......
<form method="POST" action="/default/index" id="event-notify-form">
<div id="notification-event" style="overflow: hidden; width: auto; height: 400px">
<ul>
<li data-id="171" class="nav-message-body"></li>
<li data-id="168" class="nav-message-body"></li>
</ul>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
我的jquery是
$('#notification-event li').click(function() {
var eid=$(this).attr("data-id");
$('#event-notify-form').append(eid).submit();
});
Run Code Online (Sandbox Code Playgroud)
data-id不发布,我试着$_POST显示空数组
First Array是
Array
(
[2] => Course 1
[3] => C2
[4] => COMPUTATIONAL MATHEMATICS -I
[5] => BASIC ELECTRONICS
[6] => DATA STRUCTURE
[7] => COMMUNICATION SKILL
[8] => SYSTEMS PROGRAMMING
[9] => DIGITAL LOGIC
[10] => GROUP A:ENGINEERING DRAWING & WORKSHOP
)
Run Code Online (Sandbox Code Playgroud)
我的第二个数组是
Array
(
[0] => Array
(
[course_id] => 2
)
[1] => Array
(
[course_id] => 4
)
[2] => Array
(
[course_id] => 6
)
[3] => Array
(
[course_id] => 10
)
) …Run Code Online (Sandbox Code Playgroud)