DOM对象的jQuery xy文档坐标(jQuery x y document coordinates of DOM object)
我需要得到一个DOM元素的X,Y坐标(相对于文档的顶部/左边)。 我找不到任何可以给我的插件或jQuery属性或方法。 我可以获取DOM元素的顶部和左侧,但可以相对于其当前的容器/父或文档。
I need to get the X,Y coordinates (relative to the document's top/left) for a DOM element. I can't locate any plugins or jQuery property or method that can give these to me. I can get the top and left of the DOM element, but that can be either relative to its current container/parent or to document.
原文:https://stackoverflow.com/questions/1002934
更新时间:2022-06-05 10:06
最满意答案
删除尾随的分号:
#define RESTFUL_PATH_PREFIX @"https://gogch.com/gch-restful"; ^
然后字符串常量可以由编译器连接:
@"first" @"second"
代替:
@"first"; @"second"
Remove the trailing semi-colon:
#define RESTFUL_PATH_PREFIX @"https://gogch.com/gch-restful"; ^
and then string constants can be concatenated by the compiler:
@"first" @"second"
instead of:
@"first"; @"second"
相关问答
更多-
在Swift中附加字符串(Append String in Swift)[2023-10-01]
它很简单: 对于ObjC: NSString *string1 = @"This is"; NSString *string2 = @"Swift Language"; ForSwift: let string1 = "This is" let string2 = "Swift Language" 对于ObjC AppendString: NSString *appendString=[NSString stringWithFormat:@"%@ %@",s ... -
目标C宏附加到字符串(Objective C Macro append to string)[2022-01-17]
删除尾随的分号: #define RESTFUL_PATH_PREFIX @"https://gogch.com/gch-restful"; ^ 然后字符串常量可以由编译器连接: @"first" @"second" 代替: @"first"; @"second" Remove the trailing semi-colon: #define RESTFUL_PATH_PREFIX ... -
c ++附加到字符串(c++ appending to string)[2022-01-06]
如果您正在使用std :: strings,请使用stringstream: #include#include using namespace std; string oldString = "old"; int toAppend = 5; stringstream ss(toAppend); string newString = oldString + ss.str(); "old5"将是"old5" Use stringstream if you are wo ... -
Excel宏循环并追加(Excel macro loop and append)[2022-03-04]
如果j从1变为4,它将覆盖播放器名称(在第二个循环中播放时,播放器也将被打印4次)...首先, j应该从2到4 ......其次是Cells(i, 1).Value = strPlayer应该在第二个循环之外......第三个:你已经有了附加部分。 把你已经拥有的所有东西合并在一起,我得到了这个: Sub New_Entry() Dim strPlayer As String, strTick As Integer, i As Integer, j As Integer strPlayer = In ... -
解释这个用于与strcmp()进行字符串比较的C宏(Explain this C macro used for string comparison with strcmp())[2024-02-24]
您可以自己进行扩展: if(STRCMP(some_string, "==", " blabla")) if((strcmp(some_string, " blabla") "==" 0 )) 不幸的是,我认为在"=="附近引用它会使其不正确,并且很可能无法编译。 正确的语法是: if(STRCMP(some_string, ==, " blabla")) 这是一个测试,通过使用==或!=比较来查看变量some_string代表文本" blabla" 。 (与C中的其他值一样) You can do ... -
注意:在您的问题中,每行末尾都有分号。 这将严重干扰任何使用这些宏的尝试。 所以这取决于找到DECLARE_CMD(...)行的位置和方式,以及是否可以修复分号问题。 如果它们只是一个专用的头文件,你可以这样做: #define DECLARE_CMD(func, arg) &func, my_func_type my_funcs [] { #include "file_with_declare_cmd.h" }; ......变成了: my_func_type my_funcs [] { ...
-
你必须再次评估str的参数才能看到字符串中的10 #define LEN 10 #define str_(x) #x #define str(x) str_(x) 你这样做的方式, str的参数是直接stringyfied,因此LEN到达格式。 You'd have to evaluate the argument to str once more to see the 10 inside the string #define LEN 10 #define str_(x) #x #d ...
-
在C语言中,函数没有可移植的方式来知道它的调用者。但是你是对的,宏观的工作方式是: #define smart_log(...) ( printf("[%s]: ", __func__) , printf(__VA_ARGS__) ) __func__被定义(C99 / C11 __func__ p.1) 就好像紧接在每个函数定义的开始大括号后面的声明一样 static const char __func__ [] = " function-name "; 出现了,其中function-name是词法封闭 ...
-
循环遍历数组并附加到objective-C中的字符串(looping through array and appending to string in objective-C)[2022-04-15]
正如NSGod所说, NSString上有几个方法可以连接和返回字符串。 但是,如果您计划多次追加,则可能需要使用NSMutableString ,它针对此类情况进行了优化。 例如(根据您尝试解决的问题): NSMutableString *str = [NSMutableString string]; for (int iterator = 0; iterator < count; iterator++) { if (array[iterator] != 0) { [str ap ... -
你的宏在( “ , ” )中有智能引号,而不是真正的引号( " )。 此外,作为一个良好的实践,在定义周围放置一个括号,和x ,例如: #define GET_RED_TEXT(x) ("\x1B[31m" (x) "\x1B[00m") Your macro has smart quotes in (“, ”) not real quotes ("). Also, as a matter of good practice, put a bracket round the definition, and ...