小编mar*_*vin的帖子

如何通过id和class获取元素

是否有任何替代解决方案(在 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)

提前致谢。

html javascript dom class

11
推荐指数
2
解决办法
1万
查看次数

set_time_limit 不起作用

我有一个bigintphp 课程,用于计算大数。除了时间限制外,效果很好。

我设置了时间限制

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)

php performance time-limiting

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

class ×1

dom ×1

html ×1

javascript ×1

performance ×1

php ×1

time-limiting ×1