如果没有内容,则隐藏bootstrap中的选项卡

时间:2015-10-30 16:41:27

标签: javascript jquery html twitter-bootstrap

我尝试过使用this thread,但我无法让它为我工作。当我使用这个脚本时,它会隐藏标签是否有" p"标签与否。我做错了什么?

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<div id="table_div"></div>
<div id="output"></div>

      

这是我从其他线程借来的脚本,并根据我的需要进行了修改。任何帮助将不胜感激!

<div id="product-tabs">
<ul class="nav nav-tabs" id="myTab" role="tablist">
    <li class="active"><a href="#tab1" role="tab" data-content-id="tab1" data-toggle="tab">Description</a><div class="active-border"></div></li>
    <li class="border-none"><a href="#tab2" role="tab" data-content-id="tab2" data-toggle="tab">Features &amp; Specs</a><div class="active-border"></div></li>
    <li><a href="#tab3" role="tab" data-toggle="tab" data-content-id="tab3" class="warranty-tab">Warranty</a><div class="active-border"></div></li>
        <li class="reviews-tab"><a href="#tab4" role="tab" data-content-id="tab4" data-toggle="tab">Expert Reviews</a><div class="active-border"></div></li>

  <div class="clear"></div>



</ul>


<!-- Tab panes -->
  <div class="tab-content">
  <div class="tab-pane fade in active" id="tab1">
    <div id="product-description" class="rte">

      <div class="">{{ product.description }}</div>
      <div class="">{{ product.metafields.custom_fields.ProductFeatures }}</div>
    </div>
  </div>
  <div class="tab-pane fade" id="tab2">
    <div id="product-description" class="rte">
      {{ product.metafields.custom_fields.ProductMoreInfo }}
    </div>
  </div>
  <div class="tab-pane fade" id="tab3">
    <div id="product-description" class="rte">
      {{ product.metafields.custom_fields.Warrantee }}
    </div>
  </div>
    <div class="tab-pane fade" id="tab4">
    <div id="product-description" class="rte">
      {{ product.metafields.custom_fields.ExpertReviews }}
    </div>
  </div> 

1 个答案:

答案 0 :(得分:2)

如果我正确理解了您的javascript的评论,那么您将需要这样的内容。

function TFormMain.JSONPostRequest(Server,Url,jo : String; blnSSL: Boolean): String;
var
  aBuffer     : Array[0..4096] of Char;
  Header      : TStringStream;
  BufStream   : TMemoryStream;
  BytesRead   : Cardinal;
  pSession    : HINTERNET;
  pConnection : HINTERNET;
  pRequest    : HINTERNET;
  port        : Integer;
  flags       : DWord;
begin
  Result := '';
  pSession := InternetOpen(nil, INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  if Assigned(pSession) then
  try
    if blnSSL then
      Port := INTERNET_DEFAULT_HTTPS_PORT
    else
      Port := 9000;
    pConnection := InternetConnect(pSession, PChar(Server), port, nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
    if Assigned(pConnection) then
    try
      if blnSSL then
        flags := INTERNET_FLAG_SECURE or INTERNET_FLAG_KEEP_CONNECTION
      else
        flags := INTERNET_SERVICE_HTTP;
      pRequest := HTTPOpenRequest(pConnection, 'POST', PChar(Url), nil, nil, nil, flags, 0);
      if Assigned(pRequest) then
      try
        Header := TStringStream.Create('');
        try
          with Header do
          begin
            WriteString('Host: ' + Server + ':' + IntToStr(Port) + sLineBreak);
          end;
          HttpAddRequestHeaders(pRequest, PChar(Header.DataString), Length(Header.DataString), HTTP_ADDREQ_FLAG_ADD);
          if HTTPSendRequest(pRequest, nil, 0, Pointer(jo), Length(jo)) then
          begin
            BufStream := TMemoryStream.Create;
            try
              while InternetReadFile(pRequest, @aBuffer, SizeOf(aBuffer), BytesRead) do
              begin
                if (BytesRead = 0) then Break;
                BufStream.Write(aBuffer, BytesRead);
              end;
              aBuffer[0] := #0;
              BufStream.Write(aBuffer, 1);
              Result := WideCharToString(PChar(BufStream.Memory));
            finally
              BufStream.Free;
            end;
          end
          else
            raise Exception.Create('HttpOpenRequest failed. ' + SysErrorMessage(GetLastError));
        finally
          Header.Free;
        end;
      finally
        InternetCloseHandle(pRequest);
      end;
    finally
      InternetCloseHandle(pConnection);
    end;
  finally
    InternetCloseHandle(pSession);
  end;
end;