是否有任何替代解决方案(在 JavaScript 中)来document.getElementById();
选择特定元素,同时指定 class 和 id ?
比如我有这样一个内容:
<a class="q_href" onclick="showQuestion(1)">Question 1:</a>
<div class="q_content" id="1"></div>
<a class="q_href" onclick="showQuestion(2)">Question 2:</a>
<div class="q_content" id="2"></div>
Run Code Online (Sandbox Code Playgroud)
而我想在函数中选择“问题X”链接下对应的div
function showQuestion(id)
{
var thediv = GetByClassAndId("q_content",id); // how to implement this function ?
WriteQuestionIn(thediv); //Ajax
}
Run Code Online (Sandbox Code Playgroud)
提前致谢。
我有一个bigint
php 课程,用于计算大数。除了时间限制外,效果很好。
我设置了时间限制
set_time_limit(900);
Run Code Online (Sandbox Code Playgroud)
在我的 bigint.php 文件中,它在本地主机中工作。但在我的网络主机中,当我尝试计算 999^999 时,它会产生错误
致命错误:/home/vhosts/mysite.com/http/bigint/bigint.php 第 156 行超出了最大执行时间 10 秒
这是我的代码:
public function Multiply_Digit($digit){ //class function of bigint
if($digit==0){$this->str="0";}
else
{
$len=$this->length();
$Result = new bigint("0");
$carry=0;
$current;
/*line 156:*/ for ($i = 0; $i < $len; $i++)
{
$current = $this->str[$len-$i-1] * $digit;
if ($i == 0) { $Result->str = ""+(($current + $carry) % 10); }
else{ $Result->str .= ""+(($current + $carry) % 10); }
$carry = (($current+$carry) - ($current+$carry)%10)/10;
}
$Result->str …
Run Code Online (Sandbox Code Playgroud)